Last active
May 31, 2023 17:22
-
-
Save KraXen72/270b2b8f28dda974f9e643b384e87a68 to your computer and use it in GitHub Desktop.
userscript to automatically enter spectator mode. made for https://github.com/KraXen72/crankshaft
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 auto-spectate | |
// @author KraXen72 | |
// @version 2.0.0 | |
// @desc automatically switch to spectator mode | |
// @run-at document-end | |
// ==/UserScript== | |
const has = (object, key) => Object.prototype.hasOwnProperty.call(object, key); | |
let interval = null | |
function checkSpect() { | |
if (has(globalThis, "setSpect") && typeof globalThis.setSpect === 'function') { | |
globalThis.setSpect(true) | |
clearInterval(interval) | |
this._console.log("sucessfully set spectator mode!") | |
} | |
} | |
interval = setInterval(() => checkSpect.apply(this), 250) | |
this.unload = () => clearInterval(interval) | |
return this |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment