User:Manishearth/orphantabs.js

This is an old revision of this page, as edited by Manishearth (talk | contribs) at 13:35, 14 August 2008. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
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.
addOnloadHook(function () {
var gServerPre;
var gServerPost;
gServerPre = "http://www.google.com/search?hl=en&rlz=1G1GGLQ_ENUS255&as_q="
gServerPost="&as_epq=&as_oq=&as_eq=&num=100&lr=&as_filetype=&ft=i&as_sitesearch=" + wgServer + "&as_qdr=all&as_rights=&as_occt=any&cr=&as_nlo=&as_nhi=&safe=images"
var pgname = encodeURIComponent( wgTitle );

addPortletLink("p-cactions", wgServer + "/wiki/Special:WhatLinksHere/" + pgname, "Parents", "ca-parents" , "What links here");


addPortletLink("p-cactions", gServerPre + pgname + gServerPost, "De-orphan", "ca-de-orphan", "Find all Wikipedia pages with this page name in them"); 

addPortletLink("p-cactions","javascript:deOrphanWikify(prompt(\"What page are you de-orphaning?\",\"\"))", "De-orphan-wikify", "ca-de-orphan-wikify", "Wikify to deorphan another page"); 
//intID = setInterval("checkWin()", 3000)
});
function deOrphanWikify(pgName){
var text =document.editform.wpTextbox1.value
rXP = new RegExp("([ '\"()<>,.])(" + pgName + ")([ '\"()<>,.])", "gi")
var t = text.replace(rXP, "$1[[" + pgName + " |$2]]$3")
document.editform.wpTextbox1.value = t
}
function checkWin(){
if(sWin.document.readyState = "complete"){
clearInterval(intID)
CreateArray()
}
}
function CreateArray(){
		var sLinkArray = new Array()
		var allLists = sWin.document.getElementsByTagName("ul")
		for (i=0;i<allLists.length;i++){
			if (allLists[i].className == "mw-search-results"){
				var allLinksArray = allLists[i].anchors
			}
		}
	alert(allLinkArray.toString())

};