Advertisement
Guest User

tcac

a guest
Mar 28th, 2020
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // v1.1 [tcac - twitch chest auto clicker]
  2. //   added random timer for psuedo reaction time
  3.  
  4. //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.
  5. //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')
  6. //Copy and paste all the text below this line and then press enter.
  7.  
  8. //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
  9. // you would need to add some additionally logic to wait for the page to load and the cpDiv to be a loaded element
  10.  
  11. const init = async () => {
  12.   const cpDiv = document.querySelector('div[data-test-selector="community-points-summary"]');
  13.  
  14.   try {
  15.     const results = await startObservable(cpDiv);
  16.     return results;
  17.   } catch (err) {
  18.     console.error(err);
  19.   }
  20. }
  21.  
  22. const startObservable = (aNode) => {
  23.   const observerConfig = { childList: true, subtree: true };
  24.  
  25.   return new Promise((resolve) => {
  26.     var observer = new MutationObserver(function (mutations) {
  27.       mutations = mutations.filter(i => i.type === 'childList' && i.addedNodes.length > 0);
  28.  
  29.       mutations.forEach((mutation) => {
  30.           [...mutation.addedNodes].filter(i => i.nodeType === 1).forEach(node => {
  31.  
  32.             const btn = node.querySelector('button.tw-interactive.tw-button--success');
  33.             if (btn !== null) {
  34.                 const rand = (Math.random() * 4 + 0.75).toFixed(1);
  35.                 console.warn(`AUTO CLICKING CHEST IN ${rand} SECONDS`);
  36.                 setTimeout(() => {
  37.                     btn.click();
  38.                 }, rand * 1000);
  39.             }
  40.  
  41.           });
  42.       });
  43.       resolve(mutations);
  44.     });
  45.     observer.observe(aNode, observerConfig);
  46.   })
  47. }
  48.  
  49. init();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement