Last active
December 17, 2015 07:49
-
-
Save phette23/5575987 to your computer and use it in GitHub Desktop.
Count number of edits & bytes changed on Wikipedia user's Contributions page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
// Wikipedia ships with jQuery v1.8.3 as of 5/14/13 | |
// will only count edits on the page | |
// if editor has >50 edits need to up the display limit | |
var numEdits = $( 'ul' ).eq( 0 ).find( 'li' ).length, | |
bytesChanged = 0; | |
$( '.mw-plusminus-pos, .mw-plusminus-neg' ).each( function ( el, index ) { | |
// text looks like (+###) where # of digits is variable | |
// e.g. (+3), (-45), (+1,479) | |
// so remove any commas, first 2 chars, last char, & parse as int | |
var text = $( this ).text().replace( ',', '' ), | |
len = text.length, | |
bytesThisEdit = parseInt( text.substr( 2, len - 3 ), 10 ); | |
bytesChanged += bytesThisEdit; | |
}); | |
prompt( "Hit Ctrl+C to copy.", numEdits + "\t" + bytesChanged ); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment