User:Ian Moody/monobook.js

// Name:         Wikipaedia logo // Version:      0.2 // Description:  Changes the Wikipedia logo to Wikipaedia version

addOnloadHook( function { var logo=document.getElementById('p-logo').getElementsByTagName('a')[0].setAttribute('style', 'background-image: url\(http://upload.wikimedia.org/wikipedia/en/archive/b/bc/20050401150638%21Wiki.png\)\;'); });

// Name:         Wikipedia user menu // Version:      0.4 // Description:  Adds personalised version of Template:Userinfo to all wikipedia user pages //               removes the template from pages that already have it

addOnloadHook(function { if (document.getElementById('TemplateUserinfo')) {    var templateuserinfo=document.getElementById('TemplateUserinfo');    var removetemplate=document.getElementById('bodyContent').removeChild(templateuserinfo);  }  //  var regex=/^User:([^\/]+)$/;  //  var title=document.getElementsByTagName('h1')[0].firstChild.nodeValue;  var regex=/^User:([^\/]+) - Wikipedia, the free encyclopedia$/;  var title=document.title;  if (title.match(regex)) {    var rawusername=title.match(regex);    var username=rawusername[1].replace(/ /, '_');    function addUserMenu {      var body, menu, menulinkcontribs, menulinkcontribstext, menuspacercontribs, menulinkinteriot, menulinkinteriottext, menuspacerinteriot, menulinkimages, menulinkimagestext, menuspacerimages, menulinkesu, menulinkesutext;      body=document.getElementById('bodyContent');      menu=document.createElement('div'); menulinkcontribs=document.createElement('a'); menulinkinteriot=document.createElement('a'); menulinkimages=document.createElement('a'); menulinkesu=document.createElement('a'); menu.id='TemplateUserinfo'; menu.setAttribute('class', 'plainlinks'); menu.setAttribute('style', 'position: absolute; right: 1.15em; top: 1.3em; font-size: 90%;'); menulinkcontribs.setAttribute('href', '/wiki/Special:Contributions/' + username + ''); menulinkcontribs.setAttribute('class', 'external text'); menulinkcontribs.setAttribute('title', '' + username + '\'s contributions'); menulinkcontribstext=document.createTextNode('contributions'); menulinkimages.setAttribute('href', 'http://tools.wikimedia.de/~daniel/WikiSense/Gallery.php?wikilang=en&wikifam=.wikipedia.org&img_user_text=' + username + '&order=-img_timestamp&order=-img_timestamp&format=html'); menulinkimages.setAttribute('class', 'external text'); menulinkimages.setAttribute('title', '' + username + '\'s uploaded images'); menulinkimagestext=document.createTextNode('images'); menulinkinteriot.setAttribute('href', 'http://tools.wikimedia.de/~interiot/cgi-bin/count_edits?user=' + username + '&dbname=enwiki_p'); menulinkinteriot.setAttribute('class', 'external text'); menulinkinteriot.setAttribute('title', '' + username + '\'s edit count'); menulinkinteriottext=document.createTextNode('edit count'); menulinkesu.setAttribute('href', 'http://www.math.ucla.edu/~aoleg/wp/rfa/edit_summary.cgi?user=' + username + ''); menulinkesu.setAttribute('class', 'external text'); menulinkesu.setAttribute('title', '' + username + '\'s edit summary usage'); menulinkesutext=document.createTextNode('edit summary usage'); menulinkcontribs.appendChild(menulinkcontribstext); menulinkinteriot.appendChild(menulinkinteriottext); menulinkimages.appendChild(menulinkimagestext); menulinkesu.appendChild(menulinkesutext); menuspacercontribs=document.createTextNode(' | '); menuspacerimages=document.createTextNode(' | '); menuspacerinteriot=document.createTextNode(' | '); menu.appendChild(menulinkcontribs); menu.appendChild(menuspacercontribs); menu.appendChild(menulinkimages); menu.appendChild(menuspacerimages); menu.appendChild(menulinkinteriot); menu.appendChild(menuspacerinteriot); menu.appendChild(menulinkesu); body.appendChild(menu); }   addOnloadHook(addUserMenu); }

});

// Description:  change the names of personal tools links and tabs //               stolen from User:Trilobite/monobook.js and heavily modified

function changelinks { if(!document.getElementById) { return; } if (document.createTextNode) { var mytalk, preferences, watchlist, mycontris, logout; mytalk=document.getElementById('pt-mytalk').firstChild.firstChild; mytalk.nodeValue='Talk page'; preferences=document.getElementById('pt-preferences').firstChild.firstChild; preferences.nodeValue='Preferences'; watchlist=document.getElementById('pt-watchlist').firstChild.firstChild; watchlist.nodeValue='Watchlist'; mycontris=document.getElementById('pt-mycontris').firstChild.firstChild; mycontris.nodeValue='Contributions'; logout=document.getElementById('pt-logout').firstChild.firstChild; logout.nodeValue='Log out'; if(document.getElementById('ca-nstab-user')) { var nstabuser=document.getElementById('ca-nstab-user').firstChild.firstChild; nstabuser.nodeValue='User'; }   if(document.getElementById('ca-nstab-wp')) { var nstabuser=document.getElementById('ca-nstab-wp').firstChild.firstChild; nstabuser.nodeValue='Project'; }   if(document.getElementById('ca-article')) { var nstabuser=document.getElementById('ca-article').firstChild.firstChild; nstabuser.nodeValue='Special'; }   if(document.getElementById('ca-talk')) { var talk=document.getElementById('ca-talk').firstChild.firstChild; talk.nodeValue='Talk'; }   if(document.getElementById('ca-edit')) { var edit=document.getElementById('ca-edit').firstChild.firstChild; edit.nodeValue='Edit'; }   if(document.getElementById('ca-viewsource')) { var viewsource=document.getElementById('ca-viewsource').firstChild.firstChild; viewsource.nodeValue='Source'; }   if(document.getElementById('ca-watch')) { var watch=document.getElementById('ca-watch').firstChild.firstChild; watch.nodeValue='Guard'; }   if(document.getElementById('ca-unwatch')) { var unwatch=document.getElementById('ca-unwatch').firstChild.firstChild; unwatch.nodeValue='Ignore'; } }  else { document.getElementById('pt-mytalk').firstChild.innerHTML = 'Talk page'; document.getElementById('pt-preferences').firstChild.innerHTML = 'Preferences'; document.getElementById('pt-watchlist').firstChild.innerHTML = 'Watchlist'; document.getElementById('pt-mycontris').firstChild.innerHTML = 'Contributions'; document.getElementById('pt-logout').firstChild.innerHTML = 'Log out'; if(document.getElementById('ca-nstab-user')) { document.getElementById('ca-nstab-user').firstChild.innerHTML = 'User'; }   if(document.getElementById('ca-nstab-wp')) { document.getElementById('ca-nstab-wp').firstChild.innerHTML = 'Project'; }   if(document.getElementById('ca-article')) { document.getElementById('ca-article').firstChild.innerHTML = 'Special'; }   if(document.getElementById('ca-talk')) { document.getElementById('ca-talk').firstChild.innerHTML = 'Talk'; }   if(document.getElementById('ca-edit')) { document.getElementById('ca-edit').firstChild.innerHTML = 'Edit'; }   if(document.getElementById('ca-viewsource')) { document.getElementById('ca-viewsource').firstChild.innerHTML = 'Source'; }   if(document.getElementById('ca-watch')) { document.getElementById('ca-watch').firstChild.innerHTML = 'Guard'; }   if(document.getElementById('ca-unwatch')) { document.getElementById('ca-unwatch').firstChild.innerHTML = 'Ignore'; } } }

addOnloadHook(changelinks);

// Name:         Wikipedia Purge Tab // Description:  Adds purge tab to Wikipedia pages //               stolen from User:BesigedB/monobook.js

function addPurgeButton { var href = document.location.href; if ( href.search( /[^:]*:\/\/en\.wikipedia\.org\/(wiki\/|w\/index\.php\?title=)([^&?]*)/ ) === 0 && document.getElementById('ca-history')) { var historyHref = document.getElementById( "ca-history" ).firstChild.href; var div = document.getElementById( "p-cactions" ); var ul = div.getElementsByTagName( "ul" )[0]; var newLi = document.createElement( "li" ); var newA = document.createElement( "a" ); newA.setAttribute( "href", historyHref.replace( "=history" , "=purge" ) ); if (document.createTextNode) { var text = document.createTextNode( "Purge" ); newA.appendChild( text ); }   else { newA.innerHTML='Purge'; }   newLi.appendChild( newA ); ul.appendChild( newLi ); } }

addOnloadHook(addPurgeButton);

//Main page tab no longer says main page addOnloadHook(mainpg); function mainpg { var site = location.href; if (site == 'http://en.wikipedia.org/wiki/Main_Page') { if(document.getElementById('ca-nstab-main')) { var main=document.getElementById('ca-nstab-main').firstChild.firstChild; main.nodeValue = 'Main'; }    }  else if(document.title.indexOf("Main Page") != -1) { if(document.getElementById('ca-nstab-main')) { var main=document.getElementById('ca-nstab-main').firstChild.firstChild; main.nodeValue = 'Main'; }    } }

// Name: Zero Section edit link // Version: 0.1

var disable_zero_section = 0; function edit_zero_section { if(disable_zero_section != 1 && (document.getElementById('bodyContent').innerHTML.match('class="editsection"'))) document.getElementById('bodyContent').innerHTML = ' [edit] ' + document.getElementById('bodyContent').innerHTML; } addOnloadHook(edit_zero_section);