Skip to content

Instantly share code, notes, and snippets.

@lukekarrys
Last active September 19, 2017 18:14
Show Gist options
  • Save lukekarrys/b2678181ba90a9ea8a52c9188e0552d2 to your computer and use it in GitHub Desktop.
Save lukekarrys/b2678181ba90a9ea8a52c9188e0552d2 to your computer and use it in GitHub Desktop.
Totals and Winning Percentages for NFL easyofficepools.com
javascript:(()=>{[...document.querySelectorAll(".n33table tr")].forEach(t=>{const e=t.querySelector("td:first-child span span"),[n,...r]=t.textContent.trim().split(" "),l=r.slice(5).map(t=>t.match(/\d+-\d+-\d+/)).filter(Boolean).map(t=>t[0]);if(l.length>6)return;const o=l.map(t=>t.split("-").map(Number)).reduce((t,[e,n,r])=>(t[0]+=e,t[1]+=n,t[2]+=r,t),[0,0,0]);e.textContent+=` / ${o[0]}-${o[1]}-${o[2]} / ${(o[0]/(o[0]+o[1])).toFixed(3)}`});})()
[...document.querySelectorAll('.n33table tr')].forEach((row) => {
const cell = row.querySelector('td:first-child span span')
const [name, ...rest] = row.textContent.trim().split(' ')
const teams = rest.slice(5).map((d) => d.match(/\d+-\d+-\d+/)).filter(Boolean).map((match) => { return match[0] })
if (teams.length > 6) return;
const scores = teams.map((team) => team.split('-').map(Number))
const sums = scores.reduce((acc, [win, loss, tie]) => (acc[0] += win, acc[1] += loss, acc[2] += tie, acc), [0, 0, 0])
cell.textContent += ` / ${sums[0]}-${sums[1]}-${sums[2]} / ${(sums[0] / (sums[0] + sums[1])).toFixed(3)}`
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment