Skip to content

Instantly share code, notes, and snippets.

@thecodewarrior
Last active May 30, 2024 15:15

Revisions

  1. thecodewarrior revised this gist Jan 22, 2021. 1 changed file with 28 additions and 2 deletions.
    30 changes: 28 additions & 2 deletions AutoTwitchBonus.js
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    // ==UserScript==
    // @name Auto Twitch Bonus
    // @namespace http://tampermonkey.net/
    // @version 1.0
    // @version 1.1
    // @description Automatically collect channel points
    // @author thecodewarrior
    // @match https://www.twitch.tv/*
    @@ -10,11 +10,37 @@

    (function() {
    'use strict';

    // https://stackoverflow.com/a/35385518/1541907
    function htmlToElement(html) {
    var template = document.createElement('template');
    html = html.trim(); // Never return a text node of whitespace as the result
    template.innerHTML = html;
    return template.content.firstChild;
    }

    function getBonusLabel() {
    var element = document.querySelector('.auto-bonus-label');
    if(element == null) {
    element = htmlToElement('<div class="auto-bonus-label" style="color: var(--color-text-alt-2); margin-left: 0.5rem; font-size: 0.75em;"></div>')

    let pointsIcon = document.querySelector('button .channel-points-icon');
    if(pointsIcon != null) {
    pointsIcon.parentElement.parentElement.appendChild(element);
    }
    }
    return element;
    }

    var bonusCounter = 0;

    setInterval(function() {
    let elem = document.querySelector('.claimable-bonus__icon');
    if(elem != null) {
    console.log("[Auto Twitch Bonus] Clicking bonus");
    elem.parentElement.parentElement.click();
    bonusCounter++;
    getBonusLabel().innerHTML = "(Auto Bonus x" + bonusCounter + ")";
    }
    }, 5000);
    })();
    })();
  2. thecodewarrior revised this gist Jan 14, 2021. 1 changed file with 20 additions and 1 deletion.
    21 changes: 20 additions & 1 deletion AutoTwitchBonus.js
    Original file line number Diff line number Diff line change
    @@ -1 +1,20 @@
    /* I need a URL first */
    // ==UserScript==
    // @name Auto Twitch Bonus
    // @namespace http://tampermonkey.net/
    // @version 1.0
    // @description Automatically collect channel points
    // @author thecodewarrior
    // @match https://www.twitch.tv/*
    // @downloadURL https://gist.githubusercontent.com/thecodewarrior/00e5654956eee23fcc2e8baae634ad2c/raw/AutoTwitchBonus.js
    // ==/UserScript==

    (function() {
    'use strict';
    setInterval(function() {
    let elem = document.querySelector('.claimable-bonus__icon');
    if(elem != null) {
    console.log("[Auto Twitch Bonus] Clicking bonus");
    elem.parentElement.parentElement.click();
    }
    }, 5000);
    })();
  3. thecodewarrior created this gist Jan 13, 2021.
    1 change: 1 addition & 0 deletions AutoTwitchBonus.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    /* I need a URL first */