我正在尝试删除div元素“pagecountBlock”,一旦我在网站上查看5个页面,它就会隐藏内容。我在线跟踪了几个线程无济于事,我想知道如何在网站上注入和应用css。谁能告诉我这里我做错了什么?感谢。
的manifest.json
{
"name": "CollegeProwler Ad Hide",
"description": "Hides Ads on CollegeProwler",
"version": "1.0",
"manifest_version": 2,
"icons": {
"24": "logo24.png",
"128": "logo128.png"
},
"content_scripts": [ {
"matches": ["http://collegeprowler.com/"], //where script should be injected
"css": ["hideAd.css"], //the name of the file to be injected
"js": ["hideAd.js"] //js script to inject css
} ],
"web_accessible_resources": ["hideAd.css"]
}
hideAd.css
div .pagecountBlock {
display: none !important;
}
div .lockCount {
display: none !important;
}
hideAd.js取自this thread
var style = document.createElement('link');
style.rel = 'stylesheet';
style.type = 'text/css';
style.href = chrome.extension.getURL('hideAd.css');
(document.head||document.documentElement).appendChild(style);