Skip to content

Instantly share code, notes, and snippets.

@spion
Last active February 5, 2016 18:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spion/4566803 to your computer and use it in GitHub Desktop.
Save spion/4566803 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name blog.spodeli.org colorizer
// @namespace http://spion.github.io
// @version 0.3.4
// @description Change the spodeli.org color
// @match http://b10g.spodeli.org/*
// @copyright public domain
// @grant metadata
// ==/UserScript==
;(function() {
function getColor() {
return localStorage.bgColor || '#ff00ff';
}
var styleTable = {
'.tabs-outer': { 'background-color': true },
'.sidebar .widget a:link' : { 'color': true },
'a:link' : { 'color': true },
'.blog-feeds a, .post-feeds a': {'color': true}
};
var styles = document.createElement('style');
styles.type = 'text/css';
document.head.appendChild(styles);
function changeColor(color) {
var txt = [];
for (var selector in styleTable) {
txt.push(selector,'{');
for (var prop in styleTable[selector])
txt.push(prop,':', color,';');
txt.push('}');
}
styles.innerHTML = txt.join('');
localStorage.bgColor = color;
}
changeColor(getColor());
var i = document.createElement('input');
i.id = "color";
i.type = "color"
i.className = "color";
i.value = getColor();
i.style.cursor = 'pointer';
i.style.position = 'absolute';
i.style.right = i.style.top = 0;
i.addEventListener('change', function() {
changeColor(i.value);
});
document.body.appendChild(i);
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment