CSS * :not selector in userscript under Google Chrome

标签 css google-chrome css-selectors userscripts

我正在尝试创建一个用户样式(作为用户脚本安装在 Google Chrome 中)。 这只是一些 CSS 来隐藏页面上的所有内容,只显示 an image .

html { height:100%; 
       background:url(/image/1xZIO.png) no-repeat center fixed #FFFFFF !important; 
       overflow:hidden; 
     }
*:not(html) { display:none; }

我想说我对 CSS 的理解有问题,但这在 Mozilla Firefox有效(将此代码粘贴到 userContent.css并且它的行为符合预期)。

也尝试过body而不是html , visibility:collapse;而不是display:none;更具体:not选择器。

这里是how userstyles.org makes this CSS into a userscript

请解释一下这是怎么回事!非常感谢!

最佳答案

以下代码在我的 chrome 上运行良好。我删除了您的 @namespace 行并在 html 元素上应用了样式。

// @description   Block entire websites in style!
// @author        monn43
// @homepage      http://userstyles.org/styles/53487
// @run-at        document-start
// ==/UserScript==
(function() {
var css = "";
if (false || (document.domain == "perezhilton.com" ||document.domain.substring(document.domain.indexOf(".perezhilton.com") + 1) == "perezhilton.com") || (document.domain == "fitperez.com" || document.domain.substring(document.domain.indexOf(".fitperez.com") + 1) == "fitperez.com") || (document.domain == "cocoperez.com" || document.domain.substring(document.domain.indexOf(".cocoperez.com") + 1) == "cocoperez.com") || (document.location.href.indexOf("http://perezhilton.com/") == 0))
css += "html { height:100%; background:url(http://i.imgur.com/oqhgG.png) no-repeat center fixed #FFFFFF !important; overflow:hidden; }\n*:not(html) { visibility:hidden; }";
if (typeof GM_addStyle != "undefined") {
GM_addStyle(css);
} else if (typeof PRO_addStyle != "undefined") {
PRO_addStyle(css);
} else if (typeof addStyle != "undefined") {
addStyle(css);
} else {
var heads = document.getElementsByTagName("head");
if (heads.length > 0) {
    var node = document.createElement("style");
    node.type = "text/css";
    node.appendChild(document.createTextNode(css));
    heads[0].appendChild(node); 
}
}
})();

关于CSS * :not selector in userscript under Google Chrome,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10049246/

相关文章:

javascript - 在不上传的情况下获取本地文件的内容

CSS:应用于类组合的样式?

css - 如何使用包含冒号的属性名称选择 DOM 中的元素?

html - 使用 Container-Fluid 的重叠列 Bootstrap

javascript - 我们可以在 css 中使用百分比高度吗?

javascript - chrome 控制台上没有显示任何内容,从表单中获取信息

google-chrome - 为什么我的调试器在视觉上停在错误的行?

c# - 如何使用 Selenium 和 C# 识别具有 href 属性的元素

php - CodeMirror - PHP 模式不起作用?

html - 如何在不激活水平滚动条的情况下将图像放置在包装器周围