User:2257/common.js

function fixRecentChangesLink { var link = document.getElementById('n-recentchanges').getElementsByTagName( 'a' ); link[0].href = link[0].href + "?hidemyself=1"; }

addOnloadHook( fixRecentChangesLink );

function addInfoTab { //do things mw.util.addPortletLink(		'p-cactions', 		wgScript + "?title=" + wgPageName + "&action=info",		'info',		'ca-info',		'tooltip',		'i',		document.getElementById('ca-history').nextSibling	);

//fix the excessively stupid visual bug document.getElementById('ca-info').parentNode.insertBefore(document.createTextNode("\n"), document.getElementById('ca-info'));

//if this is the info page, highlight it	if (wgAction == "info") { document.getElementById('ca-info').className += "selected"; }

}

addOnloadHook( addInfoTab );

function addWorkLink { //do things mw.util.addPortletLink(		'p-personal', 		wgScript + "?title=Twentytwofiftyseven/test2",		'work page',		'pt-workpage',		'tooltip',		'w',		document.getElementById('pt-mytalk').nextSibling	);

//fix the excessively stupid visual bug document.getElementById('pt-workpage').parentNode.insertBefore(document.createTextNode("\n"), document.getElementById('pt-workpage'));

}

addOnloadHook( addWorkLink );

// ==UserScript== // @name       phoenixthing // @namespace  http://userscripts.org/users/useridnumber // @include    http://www.mariowiki.com/* // @version    1 // @grant      none // ==/UserScript==

if (document.getElementsByClassName("mw-special-Recentchanges").length >= 0) { var lists = document.getElementsByClassName("mw-special-Recentchanges")[0] .getElementsByClassName("special");

for (var i = 0; i < lists.length; i++) { var listitems = lists[i].getElementsByTagName("li"); for (var j = 0; j < listitems.length; j++) { processListItem(listitems[j]); } } }

function processListItem (item) { var firstLinkRef = item.getElementsByTagName("a")[0].getAttribute("href"); if (firstLinkRef == "/Special:Log/block") { processBlockLog(item); } else if (firstLinkRef == "/Special:Log/delete") { processDeleteLog(item); } else if (firstLinkRef == "/Special:Log/move") { processMoveLog(item); } else if (firstLinkRef == "/Special:Log/protect") { processProtectLog(item); } }

function processBlockLog(item) { var pageTitle; var children = item.childNodes; for (var i = 0; i < children.length; i++) { if (children[i].data == " blocked ") { pageTitle = children[i + 1].innerHTML; break; } }  var logevent = document.createElement("span") logevent.setAttribute("class", "mw-logevent-actionlink"); logevent.appendChild(document.createTextNode(" (")); var link = document.createElement("a");  link.appendChild(document.createTextNode("unblock"));  link.setAttribute("title", "Special:Unblock/" + pageTitle);  var hrefTarget = "/Special:Unblock/"  hrefTarget += encodeURIComponent(pageTitle);  link.setAttribute("href", hrefTarget);  logevent.appendChild(link);  logevent.appendChild(document.createTextNode(" | "));  link = document.createElement("a");  link.appendChild(document.createTextNode("change block"));  link.setAttribute("title", "Special:Block/" + pageTitle);  var hrefTarget = "/Special:Block/"  hrefTarget += encodeURIComponent(pageTitle);  link.setAttribute("href", hrefTarget);  logevent.appendChild(link);  logevent.appendChild(document.createTextNode(")")); item.appendChild(logevent); }

function processDeleteLog(item) { var pageTitle; var children = item.childNodes; for (var i = 0; i < children.length; i++) { if (children[i].data == " deleted page ") { pageTitle = children[i + 1].getAttribute("href").split("=")[1].split("&")[0]; break; } }  var logevent = document.createElement("span") logevent.setAttribute("class", "mw-logevent-actionlink"); logevent.appendChild(document.createTextNode(" (")); var link = document.createElement("a");  link.appendChild(document.createTextNode("view/restore"));  link.setAttribute("title", "Special:Undelete");  var hrefTarget = "/index.php?title=Special:Undelete&target=";  hrefTarget += encodeURIComponent(pageTitle);  link.setAttribute("href", hrefTarget);  logevent.appendChild(link);  logevent.appendChild(document.createTextNode(")")); item.appendChild(logevent); }

function processMoveLog(item) { var oldTitle; var newTitle; var children = item.childNodes; for (var i = 0; i < children.length; i++) { if (children[i].data == " moved page ") { newTitle = encodeURIComponent(children[i + 1].getAttribute("href").split("=")[1].split("&")[0]); oldTitle = encodeURIComponent(children[i + 3].getAttribute("href").substr(1)); break; } }  var logevent = document.createElement("span") logevent.setAttribute("class", "mw-logevent-actionlink"); logevent.appendChild(document.createTextNode(" (")); var link = document.createElement("a");  link.appendChild(document.createTextNode("revert"));  link.setAttribute("title", "Special:MovePage");  var hrefTarget = "/index.php?title=Special:MovePage&wpOldTitle=";  hrefTarget += oldTitle;  hrefTarget += "&wpNewTitle=";  hrefTarget += newTitle;  hrefTarget += "&wpReason=revert&wpMovetalk=0";  link.setAttribute("href", hrefTarget);  logevent.appendChild(link)  logevent.appendChild(document.createTextNode(")")); item.appendChild(logevent); }

function processProtectLog(item) { var dateString; var pageTitle; var children = item.childNodes; for (var i = 0; i < children.length; i++) { if (i == 0) { var date = new Date(children[i]); dateString = date.getFullYear; dateString += (date.getMonth + 1); dateString += date.getDate; dateString += date.getHours; dateString += date.getMinutes; dateString += date.getSeconds; }   if (children[i].data == " changed protection level for \"") {      pageTitle = children[i + 1].getAttribute("href").substr(1);      break;    }  }  var logevent = document.createElement("span")  logevent.setAttribute("class", "mw-logevent-actionlink");  logevent.appendChild(document.createTextNode(" ("));  var link = document.createElement("a");  link.appendChild(document.createTextNode("hist"));  link.setAttribute("title", pageTitle);  var hrefTarget = "/index.php?title="  hrefTarget += encodeURIComponent(pageTitle);  hrefTarget += "&action=history&offset="  hrefTarget += date;  link.setAttribute("href", hrefTarget);  logevent.appendChild(link);  logevent.appendChild(document.createTextNode(" | "));  link = document.createElement("a");  link.appendChild(document.createTextNode("change"));  link.setAttribute("title", pageTitle);  var hrefTarget = "/index.php?title="  hrefTarget += encodeURIComponent(pageTitle); hrefTarget += "&action=protect" link.setAttribute("href", hrefTarget); logevent.appendChild(link); logevent.appendChild(document.createTextNode(")")); item.appendChild(logevent); }