Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/446.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在Google Chrome中插入CSS来隐藏某些div块?_Javascript_Html_Css_Google Chrome Extension_Content Script - Fatal编程技术网

Javascript 如何在Google Chrome中插入CSS来隐藏某些div块?

Javascript 如何在Google Chrome中插入CSS来隐藏某些div块?,javascript,html,css,google-chrome-extension,content-script,Javascript,Html,Css,Google Chrome Extension,Content Script,我试图删除一个div元素“pagecountBlock”,它在我查看网站上的5个页面时隐藏内容。我在网上关注了好几个帖子,但都没有用,我想知道如何在网站上注入和应用css。有人能告诉我我做错了什么吗?谢谢 manifest.json { "name": "CollegeProwler Ad Hide", "description": "Hides Ads on CollegeProwler", "version": "1.0", "manifest_version

我试图删除一个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取自


这不是我管理的网站。我只想删除一个一直困扰我注册的“付费墙”。虽然这个问题的答案在技术上看起来很简单,但看起来你是在试图有效地从这个网站上窃取。提供你正在使用的服务需要他们花钱。他们有权按照自己的条件提供,包括唠叨屏幕和广告。给他们一些钱,使用不同的网站,或者解释这不是盗窃服务。我已经在他们的网站上注册了。我这样做是为了学习如何制作Chrome扩展。
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);