User:Vanished user adhmfdfmykrdyr/Scripts/commonHistory.js

diffRequestLocked = "f"; if(	wgCanonicalSpecialPageName == "Watchlist" || 	wgCanonicalSpecialPageName == "Recentchanges" || 	wgCanonicalSpecialPageName == "Contributions" ||	(wgAction == "history" && !(/(.js|.css)$/.test(wgPageName)))) {	function addWatchlistInspectionBoxes { var regex; var findString; if(wgCanonicalSpecialPageName == "Contributions") {			regex = /&oldid=(\d+)$/; }		else {			regex = /&diff=(\d+)&oldid=/; }		if(wgAction == "history") {			findString = 'a:contains("prev")'; }		else {			findString = 'a:contains("diff")'; }		$("#mw-content-text ul").each(function(ind, el)		{			$(el).children("li").each(function(index, element) {				var diffLink = $(element).find(findString); if(diffLink.length > 0 && !(/(.js|.css)$/.test(diffLink[0].title))) {					var diffID = regex.exec(diffLink[0].href)[1]; var inlineDiffButton; if(typeof inlineDiffBigUI === "undefined") { 						inlineDiffButton = document.createElement("a"); inlineDiffButton.href = "#"; inlineDiffButton.innerHTML = ' [ inspect diff ] '; }					else {						inlineDiffButton = document.createElement("input"); inlineDiffButton.type = "button"; inlineDiffButton.value = "Inspect edit"; }					inlineDiffButton.id = diffID; $(inlineDiffButton).click(function{ return inspectWatchlistDiff(this);}); element.appendChild(inlineDiffButton); }			});		});		mw.loader.load('mediawiki.action.history.diff'); }	function inspectWatchlistDiff(button) {		if(diffRequestLocked === "t") {			alert("An old request is still being processed, please wait..."); return false; }		else {			diffRequestLocked = "t"; $.getJSON("/w/api.php?action=query&prop=revisions&format=json&rvprop=timestamp&rvdiffto=prev&revids="+button.id, function(response, status)			{ 				if(response == null)				{					alert("Request failed!");					diffRequestLocked = "f";					return false;				}

var diffString = response.query.pages[Object.keys(response.query.pages)[0]].revisions[0].diff["*"]; if(diffString == null) {					alert("Request failed!"); diffRequestLocked = "f"; return false; }				var newTable = document.createElement("table"); newTable.className = "diff"; $(newTable).html('  '); $(newTable).append(diffString); $(newTable).insertAfter("#"+ button.id); newTable.id = button.id + "display"; $(button).unbind("click"); if(typeof inlineDiffBigUI === "undefined") {					$(button).html(' [ hide diff ] '); $(button).click(function{ return hideSmallEditInspection(this);}); }				else {					$(button).attr("value","Hide edit"); $(button).click(function{ return hideEditInspection(this);}); }				diffRequestLocked = "f"; });		}		return false;	}	function showEditInspection(button)	{		$("#"+button.id+"display").css("display", "");		$(button).attr("value","Hide edit");		$(button).unbind("click");		$(button).click(function{ return hideEditInspection(this);});		return false;	}	function hideEditInspection(button)	{		$("#"+button.id+"display").css("display", "none");		$(button).attr("value","Show edit");		$(button).unbind("click");		$(button).click(function{ return showEditInspection(this);});		return false;	}

function showSmallEditInspection(button) {		$("#"+button.id+"display").css("display", ""); $(button).html(' [ hide diff ] '); $(button).unbind("click"); $(button).click(function{ return hideSmallEditInspection(this);}); return false; }	function hideSmallEditInspection(button) {		$("#"+button.id+"display").css("display", "none"); $(button).html(' [ show diff ] '); $(button).unbind("click"); $(button).click(function{ return showSmallEditInspection(this);}); return false; }

$(document).ready(addWatchlistInspectionBoxes); }