Skip to content

Instantly share code, notes, and snippets.

@69
Last active July 24, 2024 19:29
Show Gist options
  • Select an option

  • Save 69/b9b6565c63360176221b5d8334161929 to your computer and use it in GitHub Desktop.

Select an option

Save 69/b9b6565c63360176221b5d8334161929 to your computer and use it in GitHub Desktop.
// ==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 });
})();
@Glaived
Copy link
Copy Markdown

Glaived commented Nov 29, 2019

Great script! It would be interesting to add the automatic update feature (see Greasemonkey doc)

@pandages
Copy link
Copy Markdown

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