【发布时间】:2017-01-11 23:44:56
【问题描述】:
作为测试,我正在创建一个 chrome 扩展程序,它隐藏了 facebook 右侧的“新闻”部分和右侧的广告。同时将背景颜色更改为黑色。
我现在的问题是,当您加载 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';
【问题讨论】:
标签: javascript google-chrome google-chrome-extension content-script