【发布时间】:2013-09-07 17:28:20
【问题描述】:
我要做什么
这是一个扩展,一旦页面加载,就会隐藏一个 div,其中包含一个具有“example”类的子项。
会发生什么
什么都没有。在js 页面上,我放置的任何内容都会被忽略。我已尝试使用控制台并创建页面警报,但没有任何效果。
代码
manifest.json:
{
"name": "Example",
"version": "1.0",
"default_locale": "en",
"permissions": [
"http://example.com/*"
],
"content_scripts": [
{
"matches": [
"http://example.com/*"
],
"js": [
"js/jquery/jquery.js",
"src/inject/inject.js"
]
}
]
}
src/inject/inject.js:
chrome.extension.sendMessage({}, function(response) {
var readyStateCheckInterval = setInterval(function() {
if (document.readyState === "complete") {
clearInterval(readyStateCheckInterval);
//Nothing here actually happens
alert("Extension loaded");
console.log("Extension loaded");
//The script that I *want* to happen
$('.example-stamp').parent().parent.().parent().hide();
}
}, 10);
});
备注
jquery.js 文件是从jQuery.com 下载的最新文件。将解压后的扩展加载到 Chrome 中时没有错误,控制台中也没有出现任何错误,甚至没有错误。
我一直在 http://www.example.com 上测试它。
【问题讨论】:
标签: jquery google-chrome google-chrome-extension google-chrome-app