Skip to content

Instantly share code, notes, and snippets.

@BOLL7708
Last active July 26, 2023 17:35
Show Gist options
  • Save BOLL7708/29fe3599000003473c49bb1d62ba1d33 to your computer and use it in GitHub Desktop.
Save BOLL7708/29fe3599000003473c49bb1d62ba1d33 to your computer and use it in GitHub Desktop.
BOLL's UserScripts
// ==UserScript==
// @name Twitch Bonus Auto Claimer
// @namespace https://github.com/BOLL7708
// @homepageURL https://gist.github.com/BOLL7708/29fe3599000003473c49bb1d62ba1d33
// @downloadURL https://gist.github.com/BOLL7708/29fe3599000003473c49bb1d62ba1d33/raw/twitch-bonus-auto-claimer.js
// @match *://twitch.tv/*
// @match *://www.twitch.tv/*
// @grant GM_getValue
// @grant GM_setValue
// @version 1.0
// @author BOLL7708
// @description Will automatically click the bonus chest button that appears on a partner or affiliate Twitch page every 15 minutes of watch time.
// ==/UserScript==
// Setup
const VALUE_KEY = 'Bonus Button ARIA Labels'
const labels = GM_getValue(VALUE_KEY, ['Claim Bonus', 'Hämta'])
GM_setValue(VALUE_KEY, labels)
let clicks = 0
console.log('%cTBAC: Running, will check for button at randomized interval.', 'color: purple;')
setInterval(() => {
// Get the button
for (const label of labels) {
const buttons = document.querySelectorAll(`[aria-label^="${label}"]`)
// Report no button or click
if (buttons.length === 0) {
console.log(`%cTBAC: No button found, clicks so far: ${clicks}`, 'color: purple;')
} else {
for (const button of buttons) {
clicks++
console.log(`%cTBAC: Auto-clicking button! Clicks so far: ${clicks}`, 'font-size: 150%; color: purple;')
button.click()
}
}
}
}, (Math.random() + 1) * 20 * 1000) // 20-40 seconds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment