// ==UserScript==
// @name           Turn SearchWiki on/off
// @namespace      http://www.facesaerch.com/
// @description    Turn the Google SearchWiki feature on/off
// @include        http://www.google.com/search?*
// @include        http://www.google.co.uk/search?*
// ==/UserScript==

// License: CC creative common do what you want with it but if you give www.facesaerch.com credit, this would be nice, thx 

var off="#wml,.w10,.w20,.wcd,.wci,.wce{display:none!important}";
var on="#wml,.w10,.w20,.wcd,.wci,.wce{display:visible!important}";
var isOn = false


window.addEventListener("load", function(e) {
	var newA     = document.createElement('A');
	newA.setAttribute('href', "javascript://");
	isOn =  GM_getValue('searchwikivisible', false);
	newA.addEventListener("click", function(e) {
		if(isOn==true)
		{
			
			window.document.getElementById('searchwikicss').innerHTML = off;
			window.document.getElementById('swonoff').innerHTML='Wiki';
			GM_setValue('searchwikivisible', false)
			isOn=false;
		}
		else
		{

			window.document.getElementById('searchwikicss').innerHTML = on;
			window.document.getElementById('swonoff').innerHTML='Wiki off';
			GM_setValue('searchwikivisible', true)
			isOn=true;
		}
	}, false);
	
	
	newA.setAttribute('class', 'gb1');
	newA.setAttribute('id', 'swonoff');
	if(isOn == false)
    {
    	newA.innerHTML='Wiki';
    }
    else
    {
    	newA.innerHTML='Wiki off';
    }

	document.getElementById('gbar').appendChild(newA);
}, false);



(function () {
    var style = document.createElement('style');
    style.type = "text/css";
    isOn =  GM_getValue('searchwikivisible', false);
    if(isOn == false)
    {
    	style.innerHTML = off;
    	GM_setValue('searchwikivisible', false)
    }
    else
    {
    	style.innerHTML = on;
    	GM_setValue('searchwikivisible', true)
    }
    style.setAttribute('id', 'searchwikicss');
    
    var head = document.getElementsByTagName('head')[0];
    if (head) {
       head.appendChild(style);
    }
    isOn =false;
})();





