Last active
September 19, 2017 18:14
-
-
Save lukekarrys/b2678181ba90a9ea8a52c9188e0552d2 to your computer and use it in GitHub Desktop.
Totals and Winning Percentages for NFL easyofficepools.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)}`});})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[...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