Jump to content

User:Animum/count.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Animum (talk | contribs) at 22:36, 1 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.
//<pre><nowiki>
importScript('User:Voice of All/Addtabs/monobook.js');

function retrieveData(user) {
    var req = sajax_init_object();
    req.open("GET", "http://en.wikipedia.org/w/api.php?format=json&action=query&list=users&usprop=editcount&ususers=" + user, false);
    req.send(null);
    var info = eval("(" + req.responseText + ")").query.users[0];
    var editcount = info.editcount;
    var name = info.name;
    document.getElementById("contentSub").innerHTML += "<br /><b>" + name + " has " + editcount + " total edits.";
}

function editcount() { 
  var subpagename = wgTitle.split('/')[1];
  if((wgNamespaceNumber == '2' || wgNamespaceNumber == '3') && !subpagename) { 
    var countuser = wgTitle.split(':')[0];
    retrieveData(countuser);
  }
  if(wgNamespaceNumber == '-1' && wgTitle == 'Contributions') {
      if(!document.getElementById('contentSub')) return; 
    countuser = document.getElementById('contentSub').getElementsByTagName('a')[0].title.split(':')[1];
    retrieveData(countuser);
  }
}

function addcountedit() { 
  var subpagename = wgTitle.split( '/' )[1];
  if( (wgNamespaceNumber == '2' || wgNamespaceNumber == '3' || ( wgNamespaceNumber == '-1' && wgTitle == 'Contributions' )) && !subpagename ) { 
    addPortletLink("javascript:editcount()", String.fromCharCode(94), "", "");
  } 
}

addOnloadHook(addcountedit);

//</nowiki></pre>