Skip to content

Instantly share code, notes, and snippets.

@apnerve
Created December 11, 2018 07:29
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 apnerve/c8db4e15cf32af07396b87ddc46e1aee to your computer and use it in GitHub Desktop.
Save apnerve/c8db4e15cf32af07396b87ddc46e1aee to your computer and use it in GitHub Desktop.
Election results bookmarklet
javascript:window.results = ([].slice.apply(document.querySelectorAll('#div1 tr'))).slice(3,-1).map(row => {const cells = row.querySelectorAll('td');return {c:cells[0].innerText,p: cells[1].innerText,v:Number(cells[2].innerText)}})
@apnerve
Copy link
Author

apnerve commented Dec 11, 2018

You can get the sum of all votes except the top using results.slice(1).reduce((a,c)=> a+c.v, 0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment