Last active
July 24, 2024 19:29
-
-
Save 69/b9b6565c63360176221b5d8334161929 to your computer and use it in GitHub Desktop.
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 Twitch Channel Points autoclaimer | |
// @version 1.0.0 | |
// @description Automatically clicks the chest to claim the Twitch channel points | |
// @author jammy | |
// @match https://twitch.tv/* | |
// @match https://www.twitch.tv/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
const sel = (selector) => document.querySelector(selector); | |
let isInjected = false; | |
const init = () => { | |
const buttonObserver = new MutationObserver((mutations) => { | |
for (const mutation of mutations) { | |
const addedNodes = Array.from(mutation.addedNodes); | |
if (sel('.community-points-summary .tw-icon__svg')) { | |
setTimeout(() => { | |
sel('.community-points-summary .tw-icon__svg').parentNode.click(); | |
}, Math.random() * 5000); | |
} | |
} | |
}); | |
const pointsElement = document.querySelector('.chat-input__buttons-container'); | |
buttonObserver.observe(pointsElement, { childList: true, subtree: true }); | |
}; | |
const wrapperObserver = new MutationObserver((mutations) => { | |
for (const mutation of mutations) { | |
const addedNodes = Array.from(mutation.addedNodes); | |
if (addedNodes.includes(sel('.chat-input__buttons-container')) || sel('.chat-input__buttons-container')) { | |
if(isInjected) return; | |
init(); | |
isInjected = true; | |
console.log('injected'); | |
wrapperObserver.disconnect(); | |
} | |
} | |
}); | |
wrapperObserver.observe(document.body, { childList: true, subtree: true }); | |
})(); |
Does not appear to work at this time.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great script! It would be interesting to add the automatic update feature (see Greasemonkey doc)