2012-04-06 34 views
2

我試圖創建一個用戶樣式(作爲用戶腳本安裝在Google Chrome中)。 這只是一些CSS來隱藏頁面上的所有內容,只顯示an imageCSS *:在Chrome瀏覽器下未在userscript中選擇

html { height:100%; 
     background:url(http://i.imgur.com/oqhgG.png) no-repeat center fixed #FFFFFF !important; 
     overflow:hidden; 
    } 
*:not(html) { display:none; } 

我要說有什麼毛病我這裏CSS的理解,但這種工作Mozilla Firefox瀏覽器(在userContent.css粘貼此代碼,它的行爲如預期)。

也試過body代替htmlvisibility:collapse;代替display:none;和更具體的:not選擇。

這裏是how userstyles.org makes this CSS into a userscript

請解釋一下這是怎麼回事了!非常感謝!

+0

所以,你說它的工作原理...那麼怎麼了?你是否試圖說它在某個瀏覽器中不起作用? – BoltClock 2012-04-07 02:06:50

+0

你有沒有試過postfixing'!important'?頁面的CSS可能會覆蓋用戶的風格。 – 2012-04-07 07:55:50

回答

2

以下代碼在我的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); 
} 
} 
})(); 
+0

刪除@namespace和'visibility:hidden;'修復它,謝謝! – SouPress 2012-04-07 09:55:47

相關問題