Last active
February 5, 2016 18:01
-
-
Save spion/4566803 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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