Skip to content

Instantly share code, notes, and snippets.

@andrew-d
Created October 24, 2013 22:31
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 andrew-d/7146277 to your computer and use it in GitHub Desktop.
Save andrew-d/7146277 to your computer and use it in GitHub Desktop.
Bookmarklet to strip names on http://escape.alf.nu Note: not perfect - drops the alt text, for example.
var clear = function(){
var names = {};
var count = 0;
var tds = document.querySelectorAll('div#actualscores td');
for( var i in tds ) {
var text = tds[i].innerText;
if( text !== undefined && !text.match(/^[\d ,]+$/) ) {
var newText = text.split(', ').
map(function(x) {
if( names[x] === undefined ) {
count += 1;
names[x] = count + "";
}
return names[x];
}).
join(', ');
tds[i].innerText = newText;
}
}
};
clear();
// Bookmarklet to copy;
// javascript:(function(){ var names = {}; var count = 0; var tds = document.querySelectorAll('div#actualscores td'); for( var i in tds ) { var text = tds[i].innerText; if( text !== undefined && !text.match(/^[\d ,]+$/) ) { var newText = text.split(', '). map(function(x) { if( names[x] === undefined ) { count += 1; names[x] = count + ""; } return names[x]; }). join(', '); tds[i].innerText = newText; } } })();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment