Jump to content

User:Omegatron/monobook.js/addsincetab.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 addSinceTab() {
    if (window.location.href.indexOf("&action=history&gotosince=true")!=-1) {
       do_since_I_last_edited()
    }
    else if (!/wiki\/Special:|w\/index.php?title=Special:/.test(window.location.href)) {
       var thetitle=document.title.slice(0, String(document.title).indexOf(" - "));
       var l=addPortletLink('p-cactions', "/w/index.php?title="+thetitle+"&action=history&gotosince=true", 'since', 'ca-since', 'View diff from last edit by me', '', 'ca-history');
       l.lastChild.title="Changes since I last edited";
    }
}
function do_since_I_last_edited() {
	var csub=document.getElementById("contentSub");
	var msg=document.createElement("p");
	msg.appendChild(document.createTextNode
			("Parsing history... please wait..."));
	msg.className="error";
	csub.insertBefore(msg, csub.firstChild)

	var username=document.getElementById("pt-userpage").textContent;
	var hists=document.getElementById("pagehistory").childNodes;
	for (n=0;n<hists.length;n++) {
	    if (hists[n].getElementsByTagName("span")[0].textContent==username) {
		document.location=hists[n].childNodes[1].href; 
		return;
	    }
	}

	msg.replaceChild(document.createTextNode
			 ("You have not edited this page! (recently)"),
			 msg.firstChild);
}

$(addSinceTab);