// ==UserScript==
// @name           delo
// @namespace      fcc
// @description    Enlarge the line-height of delo.si for better readability
// @include        http://www.delo.si/*
// ==/UserScript==

(function(s){
	var addGlobalStyle = function(css) {
		var head, style;
		head = document.getElementsByTagName('head')[0];
		if (!head) {return;}
		style = document.createElement('style');
		style.className = 'fcc-grease';
		style.type = 'text/css';
		style.toggle = function() {
			if (style.innerHTML==='') {style.innerHTML = css.join("\n");}
			else {style.innerHTML = '';}
		};
		head.appendChild(style);
		style.toggle();
		return style;
	};
	var _ = function(s,d,i) {
		i = i || {};
		for (var p in s) {
			if (!i[p]) {d[p] = s[p];}
		}
	};
	var createToggler = function(o) {
		var body, elm;
		body = document.getElementsByTagName('body')[0];
		if (!body) {return;}
		elm = document.createElement('a');
		elm.href = '#on';
		elm.innerHTML = 'Greased';
		_({
			position:'fixed',
			right:'0px',
			top:'0px',
			backgroundColor:'#090',
			color:'#fff',
			cursor:'pointer',
			textDecoration:'none',
			padding:'.5em',
			zIndex:'999',
			fontSize:'10px',
			fontFamily:'Helvetica,Arial,sans-serif'
		}, elm.style);
		body.appendChild(elm);
		var fn = function(ev) {
			var ison = elm.href.indexOf('#on')>0;
			elm.style.backgroundColor = ison? '#900' : '#090';
			elm.href = ison? '#off' : '#on';
			o.toggle();
			if (ev) {ev.preventDefault();}
		};
		elm.addEventListener('click',fn, false);
		window.addEventListener('keypress',function(ev) {
			if (ev.altKey && ev.charCode==103) {fn();}
		}, false);
	};
	createToggler(addGlobalStyle(s));
})([
	'.NewsFullContent { line-height:1.5; }'
]);