Misplaced Pages

User:Animum/count.js: Difference between revisions

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
< User:Animum Browse history interactively← Previous editContent deleted Content added
Revision as of 22:32, 1 August 2008 view sourceAnimum (talk | contribs)30,489 editsm addportletlink← Previous edit Latest revision as of 19:26, 28 November 2021 view source Ladsgroup (talk | contribs)Extended confirmed users, IP block exemptions, Pending changes reviewers, Rollbackers20,548 editsm Maintenance: Replacing addPortletLink() with mw.util.addPortletLink() (mw:ResourceLoader/Migration_guide_(users)#addPortletLink
(11 intermediate revisions by 3 users not shown)
Line 13: Line 13:


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


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


addOnloadHook(addcountedit); $(addcountedit);


//</nowiki></pre> //</nowiki></pre>

Latest revision as of 19:26, 28 November 2021

//<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;
    var editcount = info.editcount;
    var name = info.name;
    document.getElementById("contentSub").innerHTML += "<br /><b>" + name + " has " + editcount + " total edits.";
}

function editcount() { 
    var subpagename = mw.config.get('wgTitle').split('/');
    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 ").split(" - ");
        retrieveData(countuser);
    }
}

function addcountedit() { 
    var subpagename = mw.config.get('wgTitle').split( '/' );
    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);

//</nowiki></pre>