User:FireFox/monobook.js

// wikiswap

function getURL(uri) { var sizeOf = location.href.length; uri.dir = location.href.substring(0, sizeOf); uri.array = uri.dir.split("/"); var arraySize = uri.array.length; uri.pagename = ""; for(var i = 3; i <= arraySize-1; i++) { if(i==arraySize-1){ uri.pagename = uri.pagename+uri.array[i]; }   else { uri.pagename = uri.pagename+uri.array[i]+"/"; } }  var isGWW = uri.array[2].indexOf("wiki.guildwars.com"); var isGWIKI = uri.array[2].indexOf("gw.gamewikis.org"); if (isGWW != -1 ) { uri.thisSite = "GWW" }; if (isGWIKI != -1 ) {uri.thisSite = "GWIKI" }; return uri }

function addPortletLink(portlet, href, text, id, tooltip, accesskey, nextnode) { var node = document.getElementById(portlet); if ( !node ) return null; node = node.getElementsByTagName( "ul" )[0]; if ( !node ) return null; var link = document.createElement( "a" ); link.appendChild( document.createTextNode( text ) ); link.href = href; var item = document.createElement( "li" ); item.appendChild( link ); if ( id ) item.id = id; if ( accesskey ) { link.setAttribute( "accesskey", accesskey ); tooltip += " ["+accesskey+"]"; } if ( tooltip ) { link.setAttribute( "title", tooltip ); } if ( accesskey && tooltip ) { updateTooltipAccessKeys( new Array( link ) ); } if ( nextnode && nextnode.parentNode == node ) node.insertBefore( item, nextnode ); else node.appendChild( item ); // IE compatibility (?) return item; }

function addTab(url, name, id, title, key) { return addPortletLink('p-cactions', url, name, id, title, key); }

// WikiSwap addOnloadHook( function {    var url = new String;    var uri = new Object;    var label = new String;    getURL(uri);    if (uri.thisSite == "GWW") {      url = "http://gw.gamewikis.org/" ;      label = "Switch to GuildWiki";    }    if (uri.thisSite == "GWIKI") {       url = "http://wiki.guildwars.com/"       label = "Switch to GWW";    }    url = url + uri.pagename;    addTab(url, "Switch", "ca-swap", label, "");  } );