Skip to content

Instantly share code, notes, and snippets.

@KraXen72
Last active May 31, 2023 17:22
Show Gist options
  • Save KraXen72/270b2b8f28dda974f9e643b384e87a68 to your computer and use it in GitHub Desktop.
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
// ==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