MediaWiki:Common.js/User:Fumple/EditCount.js

// // var msgs = [ "That user made more than 500 edits. This will take longer...", "Hmm 1000 edits... nice! More time please!", "1500",   "Woah 2000? That's a lot!", "And we keep going... 2500", "User edit counter 3000", "AM I LIKE DISCORD YET? 3500", "WHAT? 4000? DAAMN", "4500",   "5000! Okay, this is epic!", "More? cmon! I don't have time to keep writing this!", "6000! Inkoming edits!", "6500! Wow this place is crowded", "7000! I ran out of ideas", "7500! Nevermind, keep going!", "8000! OCTO EXPANSION!?!?!?", "8500! END ALREADY! I want to be done...", "9000!",   "IT'S OVER 9000!!!!", "10000! OH MY GOD. 10000???", "Okay no more, 10500", ] var curredit = 0; var oldlen = 0; var tempedit = []; $("#user-edits").append(' '); $("#load").css("display", "none"); $("#user-edits-button").click(function {    $("#user-edits-name").attr("disabled", "")    $("#user-edits-button").attr("disabled", "")    curredit = 0;    oldlen = 0;    tempedit = [];    new mw.Api.get({ "action": "query", "list": "usercontribs", "uclimit": "500", "ucprop": "tags|title", "ucuser": $("#user-edits-name")[0].value })       .done(done)        .fail(function (err) { $("#load").html("An unexpected error occured!"); $("#load").css("display", ""); console.log(err) }) }) function done(data) { if (data.continue != null) { oldlen += data.query.usercontribs.length; $("#load").html((msgs[curredit] || oldlen)+" "); curredit++; tempedit = tempedit.concat(data.query.usercontribs); new mw.Api.get({           "action": "query",            "list": "usercontribs",            "uclimit": "500",            "ucprop": "tags|title",            "ucuser": $("#user-edits-name")[0].value,            "uccontinue": data.continue.uccontinue        }) .done(done) .fail(function (err) {               $("#load").html("An unexpected error occured!");                $("#load").css("display", "");                console.log(err)            }) return; }   oldlen += data.query.usercontribs.length; tempedit = tempedit.concat(data.query.usercontribs); var filtered = tempedit.filter(function (a) { return a.tags.indexOf("mw-new-redirect") == -1 }); filtered = filtered.filter(function (a) { return !a.title.startsWith("User:") }); var newlen = filtered.length; console.log(data) $("#user-edits-name").attr("disabled", null) $("#user-edits-button").attr("disabled", null) $("#load").html("Found " + newlen + " proper edits (" + oldlen + " total edits) " + Math.floor(newlen / oldlen * 100) + "% of edits are proper"); $("#load").css("display", ""); }