Skip to content

Instantly share code, notes, and snippets.

@WillForan
Created October 12, 2020 19:12
Show Gist options
  • Save WillForan/0641e40e8d7bbda8710904ccf3acfc72 to your computer and use it in GitHub Desktop.
Save WillForan/0641e40e8d7bbda8710904ccf3acfc72 to your computer and use it in GitHub Desktop.
count territories: update each gamesByEmail.com Gambit players status box w/ territory count
colors={'255, 255, 0': 'Yellow', '0, 255, 0': 'Green', '255, 0, 255': 'Magenta', '255, 0, 0': 'Red', '0, 255, 255': 'Cyan', '0, 0, 255': 'Blue' };
cnt={};
a=[... document.querySelectorAll('div[style~="background-color:"]')].map(x=>colors[x.getAttribute('style').replace(/.*background-color: rgb\((.*?)\); color.*/,'$1')]).forEach(function(x) {cnt[x] = cnt[x]===undefined?1:cnt[x]+1});
Object.keys(cnt).forEach(k=>$('font[title="'+k+'"]').children[2].innerHTML+= ", " + cnt[k] + "terr.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment