Skip to content

Instantly share code, notes, and snippets.

@phette23
Last active December 17, 2015 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phette23/5575987 to your computer and use it in GitHub Desktop.
Save phette23/5575987 to your computer and use it in GitHub Desktop.
Count number of edits & bytes changed on Wikipedia user's Contributions page
(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