jQuery prepend()方法无法在Chrome扩展程序中的某些网站上运行

时间:2015-10-12 07:37:36

标签: javascript jquery google-chrome-extension prepend

我正在尝试在网页主体中注入一个div,它在我尝试的所有网页上都能完美运行,除了某些网站,即bbc.co.uk,nytimes.com和stackoverflow.com。我怀疑它是因为身体没有加载,但是我在$(document).ready()中这样做并不是真的有意义。

$(document).ready(function() {
    $('body').prepend('<div id="tilda"></div>');
});

正如我所说,这可以很好地作为Chrome扩展注入大多数页面,只是一些似乎免疫?

根据评论编辑:

我的inject.js文件如下:

$(document).ready(function() {
    $('body').prepend('<div id="tilda"></div>');
    console.log($('body'))
});

我包含了像这样的js文件:

“content_scripts”:[

    {
      "matches": ["https://*/*"],
      "js": ["js/jquery-1.9.1.min.js", "src/inject/inject.js"]
    }
 ]

某些网站以某种方式阻止从扩展程序注入dom。非常困惑!

0 个答案:

没有答案
相关问题