User:PakWalker/common.js

function editlead { if (wgCanonicalNamespace != "Special") { var header = document.getElementsByTagName('h1'); var headerHTML = header[0].innerHTML; var anchor = document.createElement('a'); anchor.href = "/w/index.php?title=" + wgPageName + "&action=edit&section=0"; anchor.innerHTML = "edit"; var span = document.createElement('span'); span.setAttribute('class', "editsection"); span.appendChild(document.createTextNode("[")); span.appendChild(anchor); span.appendChild(document.createTextNode("]")); header[0].appendChild(span); } }

addOnloadHook(editlead);

function prettify { var blocklinks = getElementsByClassName(document.getElementById('bodyContent'),"*","mw-usertoollinks"); var barfoo = new Array; for (var j = 0; j< blocklinks.length; j++) { barfoo = blocklinks[j].getElementsByTagName('a'); if (barfoo.length == 3) { var ta = barfoo[0]; ta.innerHTML = "t"; var ca = barfoo[1]; ca.innerHTML = "c"; var ba = barfoo[2]; ba.innerHTML = "b"; }   if (barfoo.length == 2) { var ta = barfoo[0]; ta.innerHTML = "t"; var ba = barfoo[1]; ba.innerHTML = "b"; }  } }

addOnloadHook(prettify);

function hidelog { if (mw.config.get('wgCanonicalSpecialPageName') === 'Watchlist') { var x = document.getElementsByTagName("li"); var z = new Array; for (var j = 0; j< x.length; j++) { var y = x[j].getElementsByTagName("a"); for (var k = 0; k< y.length; k++) { if (y[k].getAttribute("title") == "Special:Log/delete"||y[k].getAttribute("title") == "Special:Log/block") { z[j] = 1 }     }    }    for (var i = 0; i< x.length; i++) { if (z[i] == 1) { x[i].id = "kill"; }   }  } }

addOnloadHook(hidelog);

function qbonc(stuff,target, func) { stuff.onclick = function {func(target);} }

function rollitback(params) { var orly = confirm("Rollback?"); if (orly) { var req = sajax_init_object; req.open("POST", wgServer + wgScriptPath + "/index.php", true); req.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); req.setRequestHeader("Content-length", params.length); req.send(params); alert(wgServer + wgScriptPath + "/index.php?" + params); } }

function botrollback { var rollbacklinks = getElementsByClassName(document.getElementById('bodyContent'),"*","mw-rollback-link"); var botrblinks = new Array; var rbalinks = new Array; for (var j = 0; j< rollbacklinks.length; j++) { var rbbs = document.createElement('span'); var rba = rollbacklinks[j].getElementsByTagName('a')[0]; var rbba = document.createElement('a'); rbba.innerHTML = "bot rv"; rbba.href = rba.href + '&bot=1'; rbalinks[j] = rba.href; if ( rollbacklinks[j].innerHTML[0] == "[" ) rbbs.appendChild(document.createTextNode("[")); rbbs.appendChild(rbba); if ( rollbacklinks[j].innerHTML[rollbacklinks[j].innerHTML.length-1] == "]" ) rbbs.appendChild(document.createTextNode("]")); if (rollbacklinks[j].nextSibling == undefined) { rollbacklinks[j].parentNode.appendChild(document.createTextNode(" ")); rollbacklinks[j].parentNode.appendChild(rbbs); } else { rollbacklinks[j].parentNode.insertBefore(rbbs,rollbacklinks[j].nextSibling); rollbacklinks[j].parentNode.insertBefore(document.createTextNode(rbbs.nextSibling.textContent),rbbs); }     botrblinks.push(rbbs); rba.innerHTML = "rv"; rba.href = ""; qbonc(rba,rbalinks[j].substring(36,rbalinks[j].length),rollitback); } for (var j = 0; j< botrblinks.length; j++) { botrblinks[j].className = "mw-rollback-link"; } }

addOnloadHook(botrollback);

function gettoken_api { var api = sajax_init_object; api.open('GET', wgServer + wgScriptPath + '/api.php?format=json&action=query&prop=info&indexpageids=1&intoken=edit&titles=Whatever', false); api.send(null); if(api.status==200) { var response = eval('(' + api.responseText + ')'); var token = response['query']['pages'][response['query']['pageids'][0]]['edittoken']; } else { alert('The token query returned an error.'); } return token; } function hotvandal(target) {	var req = sajax_init_object; var params = "action=submit&wpVandAddress=" + encodeURIComponent(target) + "&wpAnonOnly=0&wpEnableAutoblock=1&wpCreateAccount=1&wpVandReasonList=other&wpVandReason=Quick-kicking%20for%20unfunny%20wandalism&wpEditToken=" + encodeURIComponent(gettoken_api); req.open("POST", wgServer + wgScriptPath + "/index.php?title=Special:VandalBrake", true); req.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); req.setRequestHeader("Content-length", params.length); req.onreadystatechange = function {		if(req.readyState==4) {			if(200 == req.status) {				alert("And another one bites the dust..."); } 			else {				alert('Oh noes! ' + req.responseText); }			}		};	var orly = confirm("Do you really want to vandal bin " + target + "?"); if (orly) {		req.send(params); }	} function init_hotvandal {	var anchors = document.getElementsByTagName("a"); for (i in anchors) {		if (anchors[i].title != undefined && anchors[i].title.indexOf("Special:Block/") != -1) {			target = anchors[i].title.substring(14,anchors[i].title.length); var qba = document.createElement('a'); qba.innerHTML = "v"; qba.style.cursor = "crosshair"; qbonc(qba,target,hotvandal); if (anchors[i].nextSibling == undefined) {				anchors[i].parentNode.appendChild(document.createTextNode(" | ")); anchors[i].parentNode.appendChild(qba) } 			else {				anchors[i].parentNode.insertBefore(qba,anchors[i].nextSibling); anchors[i].parentNode.insertBefore(document.createTextNode(" | "),qba); }			}		}	} addOnloadHook(init_hotvandal);