User:Pfctdayelise/Cookieblock.js

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
/* <pre>  */

//This makes cookie based blocking, a form of squishy (as opposed to hard) security, possible.
//Cookie based blocking offers greater control such as upload-only blocks, but can be more 
//easily defeated.

//For usage instructions please see [[MediaWiki talk:Cookieblock.js|the Talk page]].

function checkevilbit() {
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		if (c.replace(/^\s+|\s+$/g,"") == "evilbit=True") {
                        if (document.getElementById("wpSave"))
                            document.getElementById("wpSave").disabled=true;

                        if (document.getElementsByName("wpUpload")[0]) 
                            document.getElementsByName("wpUpload")[0].disabled=true
                       
                } 
		if (c == "evilbit=Upload") {
                        if (document.getElementsByName("wpUpload")[0]) 
                            document.getElementsByName("wpUpload")[0].disabled=true
                } 
	}
}

$(checkevilbit);

/* </pre> */