Twitch Auto Points Claimer

Get Simple floating chest

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Twitch Auto Points Claimer 
// @namespace    http://tampermonkey.net/
// @version      0.42
// @description  Get Simple floating chest
// @author       Bash62
// @match        https://www.twitch.tv/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    var numPoints = 0;
    var compteurAsLoaded = false;
    var label = document.createElement("p");




    //Check if box is active
    function checkPage(){

     // Check if the user is looking at a stream
        if(document.body.contains(document.getElementsByClassName('community-points-summary')[0])){
            //Check if loot is claimable.
            if(document.body.contains(document.getElementsByClassName("community-points-summary tw-align-items-center tw-flex tw-full-height")[0].getElementsByTagName("BUTTON")[1])){
                              var boutton = document.getElementsByClassName("community-points-summary tw-align-items-center tw-flex tw-full-height")[0].getElementsByTagName("BUTTON")[1];
                              boutton.click();
                              numPoints+=50;
                              updateCompteur();

                                      }

        }
    }

    // update numPoints :

    function updateCompteur(){
        label.innerHTML = "+" + numPoints.toString();

    }


    // Setup a numPoints that shows the number of channel points earned

    function setCompteur(){
        if(document.body.contains(document.getElementsByClassName("tw-align-items-center tw-flex tw-flex-wrap tw-full-width tw-justify-content-end tw-mg-l-1 tw-mg-t-05")[0])){
            compteurAsLoaded = true;
            var base = document.getElementsByClassName("tw-align-items-center tw-flex tw-flex-wrap tw-full-width tw-justify-content-end tw-mg-l-1 tw-mg-t-05")[0];
            label.innerHTML = "+" + numPoints.toString();
            base.appendChild(label);
        }
        else{
            // While page is not loaded wait
            // When page is loaded : setCompteur()
            setTimeout(function(){
                console.log("Waiting for page to fully load.");
                setCompteur();

            }, 1000);

        }
    }



    function main() {
        setTimeout(function() {


            setCompteur();
            checkPage();
            main();



        }, 5000);
    }

    main();

})();