Skip to content

Instantly share code, notes, and snippets.

@0mg
Created October 29, 2011 08:02
Show Gist options
  • Save 0mg/1324219 to your computer and use it in GitHub Desktop.
Save 0mg/1324219 to your computer and use it in GitHub Desktop.
UserCSS.js for Opera
// ==UserScript==
// @name UserCSS
// @include *
// ==/UserScript==
(function() {
function userCSS(event) {
[
{
url: "http://example.com/",
css: "#side{display:none!important}"
},
{
url: "http://example.org/",
css: "body{font-size:80%!important}"
}
].forEach(function(list) {
if (location.href.indexOf(list.url) >= 0) {
var style = document.createElement("style");
style.textContent = list.css;
document.head.appendChild(style);
}
});
}
opera.addEventListener("BeforeCSS", function(event) {
opera.removeEventListener(event.type, arguments.callee, false);
userCSS.apply(null, arguments);
userCSS = function() {};
}, false);
addEventListener("DOMContentLoaded", function(event) {
userCSS.apply(null, arguments);
userCSS = function() {};
}, false);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment