Last active
February 22, 2016 10:44
-
-
Save lilliliilil/9fdd4e293f9f5de54253 to your computer and use it in GitHub Desktop.
Installation link: https://gist.github.com/thepheer/9fdd4e293f9f5de54253/raw/CSGL%2520Total%2520Value.user.js
This file contains hidden or 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
| // ==UserScript== | |
| // @name CSGL Total Value | |
| // @version 0.1 | |
| // @match *://csgolounge.com/mybets | |
| // @grant none | |
| // ==/UserScript== | |
| function value(item) { | |
| return +item.querySelector('.value').textContent.slice(2); | |
| } | |
| function total(items) { | |
| return [].reduce.call(items, function(total, item) { | |
| return total + value(item); | |
| }, 0); | |
| } | |
| function render(header, items) { | |
| header = document.querySelector(header); | |
| items = document.querySelectorAll(items + ' .item'); | |
| header.textContent = header.textContent | |
| .replace(/(.*[a-z]).*/i, '$1: $$' + total(items).toFixed(2)); | |
| } | |
| function update() { | |
| render('#betreturns > :nth-child(1)', '#betreturns > :nth-child(2)'); // won | |
| render('#betreturns > :nth-child(3)', '#betreturns > :nth-child(1n+4)'); // returned | |
| render('#betreturns ~ div', '#betreturns ~ form'); // requested | |
| } | |
| render('.box:nth-child(1) .title', '.box:nth-child(1)'); // bets | |
| render('.box:nth-child(2) .title', '.box:nth-child(2)'); // returns | |
| update(); | |
| new MutationObserver(update) | |
| .observe(document.querySelector('#betreturns'), | |
| { childList: true, subtree: true }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment