我正在使用Greasemonkey並嘗試在特定域中添加規則。但它導致錯誤說The operation is insecure
。
該代碼在Chrome上正常工作。嘗試將規則添加到CSS樣式表給出Firefox中的「操作不安全」
劇本上http://mydomain.com/test/test.php
運行和CSS文件是http://cdn.mydomain.com/test/css/global.css
我的功能:
function css(selector, property, value) {
for (var i=0; i<document.styleSheets.length;i++)
{
try
{
document.styleSheets[i].insertRule(selector+ ' {'+property+':'+value+'}', document.styleSheets[i].cssRules.length);
}
catch(err)
{
try // IE
{
document.styleSheets[i].addRule(selector, property+':'+value);
}
catch(err) {}
}
}
}
在谷歌,我發現,這可能是因爲我試圖訪問的交叉領域,所以我嘗試將CSS文件的網址添加到「接受的網址」,但沒有結果。
我該如何解決這個問題?
時尚的Chrome擴展確實在添加樣式到特定域的一個偉大的工作:https://chrome.google.com/webstore/detail/stylish/fjnbnpbmkenffdnngjfgmeleoegfcffe?hl = en – 2013-03-05 16:51:39
它適用於Chrome,它不適用於Firefox。 – MetaDebugger 2013-03-05 18:01:50
[適用於Firefox的時尚](https://addons.mozilla.org/en-US/firefox/addon/stylish/)的效果甚至超過Chrome版本。 (例如,Chrome與iframe有問題。) – 2013-03-05 20:44:44