Jump to content

User:Aidan9382/scripts/noedit.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
$(function() {
	function notify(title,message,type,autohide,autohidetime) {
		if (mw.notification) {
			console.log("notify",title,message);
			autohide = (autohide==null && true) || autohide;
			autohidetime = (autohidetime==null && "short") || autohidetime;
			if (!mw.notification.autoHideSeconds[autohidetime])
				mw.notification.autoHideSeconds[autohidetime] = autohidetime; //Enable custom arbitrary lengths
			mw.notification.notify(message,{autoHide:autohide,autoHideSeconds:autohidetime,title:title,type:type});
		}
	}
	
	if (mw.config.get("wgCanonicalSpecialPageName") == "Movepage" || document.getElementById("wpTextbox1")) {
		if (document.title.indexOf(".js") == -1 && document.title.indexOf(".css") == -1) {
			notify("No edit enforcer","Edits are disabled via js","warn",false);
			window.location = "https://en.wikipedia.org/wiki/Main_Page";
		} else {
			notify("No edit enforcer","Keep in mind the no edit enforcer is active (though does not apply to .js or .css pages)","warn",false);
		}
	}
});