テストとして、Facebookの右側にある「ニュース」セクションと右側の広告を隠すクロム拡張を作成しています。また、背景色を黒に変更します。Chrome拡張機能のコンテンツスクリプトjavascript - run_at document_endが正しく動作しない
私の今の問題は、Facebookにロードするとニュースと白い背景がわずかに表示されて消えてしまうことです。だからrun_at
をdocument_end
に設定すると、ページが既に読み込まれた後にjavascriptが実行されるように見えます。私はdocument_start
とdocument_idle
も同様の結果を試してみました。ニュースセクションがまったく表示されないようにするにはどうすればよいですか?
manifest.jsonを:
{
"manifest_version": 2,
"name": "FB_Trending_Hide_ChromeExtension",
"description": "This extension will hide the trending news section of Facebook",
"version": "1.0",
"browser_action": {
"default_icon": "icon.png"
},
"content_scripts": [{
"run_at": "document_end",
"matches": ["*://*.facebook.com/*"],
"js": ["content.js"],
"all_frames": true
}],
"permissions": [
"tabs", "*://*.facebook.com/*", "activeTab"
]
}
content.js:
document.getElementById("pagelet_trending_tags_and_topics").style.display = 'none';
document.getElementById("pagelet_ego_pane").style.display = 'none';
document.body.style.background = 'black';
素晴らしい、ありがとうを! –