Created
December 20, 2017 23:54
-
-
Save lambdatastic/1674c4a961fc508d8122e0c8498ca162 to your computer and use it in GitHub Desktop.
Salty Bets console stuff
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.body.appendChild((() => { const ele = document.createElement('script'); ele.src = "//cdnjs.cloudflare.com/ajax/libs/ramda/0.25.0/ramda.min.js"; return ele; })()); | |
const betTools = {}; | |
// strings for ids | |
const targets = { | |
input: "wager", | |
buttonPrefix: "player" | |
} | |
const setValue = (elem, val) => elem.value = val | |
const genButtonId = (x) => '' + targets.buttonPrefix + x | |
const getElemById = (x) => document.getElementById(x) | |
const clickElem = (elem) => elem.click() | |
betTools.setBet = R.useWith( | |
setValue, | |
[ | |
getElemById, | |
R.identity | |
] | |
)(targets.input) | |
betTools.pickWinner = R.compose( | |
clickElem, | |
getElemById, | |
genButtonId | |
) | |
betTools.betOn = (player, amount) => {betTools.setBet(amount);betTools.pickWinner(player)} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment