User:Manishearth/monobook.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.
//Purger 
importScript("User:Manishearth/purger.js");

//My imports are at [[User:Manishearth/imports.js]]

//workaround for mass rollback script in Vector
function rollbackEverythingButton() {
  var hasRollback = document.getElementsByClassName("span", "mw-rollback-link");
  if (hasRollback[0] && (document.title.indexOf("User contributions") != -1) ) {
    mw.util.addPortletLink('p-interaction', 'javascript:rollbackEverything()', "rollback all", "ca-rollbackeverything", "rollback all edits displayed here");
  }
}
$(rollbackEverythingButton);
function rollbackEverything() {
if(confirm("Sure you want to mass rollback?")&&confirm("Sure that you are sure?")&&confirm("SURE? Will you ever regret it?")){
 
    for (var i in document.links) {
      if (document.links[i].href.indexOf('action=rollback') != -1) {
        window.open(document.links[i].href);
      }
    }
 }
}

$(function(){
//Keyboard shtcts
if(document.getElementById('prefcontrol')){document.getElementById('prefcontrol').accessKey="s"} //prefs save button

})
//cookie support
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}


//wikiEd configuration (I stopped using it, but keeping it in case I want to switch back. I'm happy with beta editbox)
wikEdRegExTypoFix = true;
var wikEdShowUsingButton = true
var wikEdShowSourceButton = true;