Jump to content

User:JeremyMcCracken/contribstab.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by JeremyMcCracken (talk | contribs) at 09:11, 12 April 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.
//Write your own! See Wikipedia:WikiProject User scripts/Guide

addOnloadHook(contribstab); //means «execute func_start later»
 
function contribstab (){

if (wgNamespaceNumber == 2 || wgNamespaceNumber == 3) {
  //If we're in User or User talk namespace

var pagename;
var name1;
var name2;

name1=wgPageName.indexOf(":");
  //Find the colon to separate User: prefix

if (name1 != -1) {
  //Skip it if we didn't find a colon
  name1=name1+2;
  pagename=wgPageName.substring(name1);
}
else
{
  pagename=wgPageName;
  //if no colon, assume we have the user name already
}

name2=pagename.indexOf("/");
  //If it's a subpage, get root name

if (name2 > 0){
  //if we found a slash earlier
  name2=name2-1;
  pagename=pagename.substring(0,name2);
}

addPortletLink ('contribs', '/wiki/Special:Contributions/'+pagename, 'Contributions', 1, 'View this user's contributions'); 
  //Add the button

document.write('name1 '+name1+' name2 '+name2+' pagename '+pagename);

  }
//resumes here for non-user/UT pages
}

//Written by Jeremy McCracken April, 2008
//Original file location http://en.wikipedia.org/wiki/User:JeremyMcCracken/contribstab.js