私がやろうとしていること
これは、ページが読み込まれると、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
。