Last active
July 21, 2020 18:59
-
-
Save jtrussell/3a629872b087beb90898593220938308 to your computer and use it in GitHub Desktop.
TCO Lobby Defaults
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
// ==UserScript== | |
// @name TCO Lobby Defaults | |
// @namespace http://tampermonkey.net/ | |
// @version 0.6 | |
// @description Set defaults for things like "Only show new games" | |
// @author jtrussell | |
// @include /https?://(www.)?thecrucible.online(\/.*)?/ | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict' | |
/** | |
* Set your default preferences here | |
*/ | |
const BEGINNER = false | |
const CASUAL = false | |
const COMPETITIVE = true | |
const NORMAL = true | |
const SEALED = false | |
const REVERSAL = false | |
const ONLY_SHOW_NEW_GAMES = true | |
function setCheckboxValue (el, isChecked) { | |
if (el.checked !== isChecked) { | |
el.click() | |
} | |
} | |
function setDefaults () { | |
[ | |
[document.getElementById('beginner'), BEGINNER], | |
[document.getElementById('casual'), CASUAL], | |
[document.getElementById('competitive'), COMPETITIVE], | |
[document.getElementById('normal'), NORMAL], | |
[document.getElementById('sealed'), SEALED], | |
[document.getElementById('reversal'), REVERSAL], | |
[document.getElementById('onlyShowNew'), ONLY_SHOW_NEW_GAMES] | |
].forEach(_ => setCheckboxValue(_[0], _[1])) | |
} | |
const _pushState = window.history.pushState | |
window.history.pushState = function userScriptPushState () { | |
const args = Array.prototype.slice.apply(arguments) | |
setTimeout(setDefaults, 300) | |
_pushState.apply(window.history, args) | |
} | |
setDefaults() | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment