Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // v1.1 [tcac - twitch chest auto clicker]
- // added random timer for psuedo reaction time
- //Note: This may not support all browsers, tested on firefox only. This is just a quick script I made in 10 minutes, so features are limited.
- //Go to your dev console on your browser for any stream that supports channel points. (You can open it with the keyboard shortcut CTRL + SHIFT + i and click on the tab that says 'console')
- //Copy and paste all the text below this line and then press enter.
- //If you want this to run automatically everytime you load a twitch page, I would recommend creating a user script using Grease Monkey https://wiki.greasespot.net/Main_Page
- // you would need to add some additionally logic to wait for the page to load and the cpDiv to be a loaded element
- const init = async () => {
- const cpDiv = document.querySelector('div[data-test-selector="community-points-summary"]');
- try {
- const results = await startObservable(cpDiv);
- return results;
- } catch (err) {
- console.error(err);
- }
- }
- const startObservable = (aNode) => {
- const observerConfig = { childList: true, subtree: true };
- return new Promise((resolve) => {
- var observer = new MutationObserver(function (mutations) {
- mutations = mutations.filter(i => i.type === 'childList' && i.addedNodes.length > 0);
- mutations.forEach((mutation) => {
- [...mutation.addedNodes].filter(i => i.nodeType === 1).forEach(node => {
- const btn = node.querySelector('button.tw-interactive.tw-button--success');
- if (btn !== null) {
- const rand = (Math.random() * 4 + 0.75).toFixed(1);
- console.warn(`AUTO CLICKING CHEST IN ${rand} SECONDS`);
- setTimeout(() => {
- btn.click();
- }, rand * 1000);
- }
- });
- });
- resolve(mutations);
- });
- observer.observe(aNode, observerConfig);
- })
- }
- init();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement