User:Animum/count.js

// 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 += " " + name + " has " + editcount + " total edits."; }

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

function addcountedit { var subpagename = mw.config.get('wgTitle').split( '/' )[1]; if(((mw.config.get('wgNamespaceNumber') == 2 || mw.config.get('wgNamespaceNumber') == 3) && typeof(subpagename) == "undefined") || mw.config.get('wgCanonicalSpecialPageName') == "Contributions") { mw.util.addPortletLink("p-cactions", "javascript:editcount", String.fromCharCode(47), "ca-editcount"); } }

$(addcountedit);

//