twitch自動點擊獎勵

自動點擊50獎勵

As of 2020-08-22. See the latest version.

// ==UserScript==
// @name         twitch自動點擊獎勵
// @namespace    http://tampermonkey.net/
// @version      2.8
// @description  自動點擊50獎勵
// @author       聖冰如焰
// @match        https://www.twitch.tv/*
// @grant        none
// @license      BY-NC-SA 3.0 TW
// ==/UserScript==

let style = document.createElement("style");
style.textContent = `
.self{
    padding : 0 10px 0 10px;
    align-items: center!important;
    position: relative;
}
.self:hover{
    background-color: rgba(0,0,0,.05);
}
.self::before{
    content: '';
}
.self:hover::before{
    content: '自動領取獎勵數';
    user-select: none;
    background-color: #040109;
    border-radius: 4px;
    color: #fff;
    font-size: 1.2rem;
    font-weight: 600;
    right: 0;
    line-height: 1.2;
    padding: 3px 6px;
    padding-top: 3px;
    padding-right: 6px;
    padding-bottom: 3px;
    padding-left: 6px;
    pointer-events: none;
    position: absolute;
    text-align: left;
    user-select: none;
    white-space: nowrap;
    z-index: 2000;
    top: 50%;
    transform: translate(110%,-50%);
}
`;
let bool = true;
let get_coin = 0;
let x = document.cookie.split(" ").map(e=>{return e.split("=")});
x.forEach(e => {
    if (e[0] == "gift"){
        get_coin = parseInt(e[1].split(";")[0]);
        bool = false;
    }
    return false;
});
if (bool) document.cookie = `gift=${0}; path=${location.pathname};expires=${new Date(+new Date()+31536000000).toString()}`;
document.head.append(style);
let button = document.createElement("button");
button.className = "self";
let timeout = 50;
(function get_coins(){
    timeout = 50;
    if (document.getElementsByClassName("tw-flex tw-flex-row").length == 3 && document.getElementsByClassName("self").length == 0){
        button.textContent = (get_coin).toLocaleString();
        document.getElementsByClassName("tw-flex tw-flex-row")[1].after(button);
    }
    if(document.getElementsByClassName("tw-button tw-button--success tw-interactive")[0] != undefined){
        document.getElementsByClassName("tw-button tw-button--success tw-interactive")[0].click();
        get_coin += 50;
        button.textContent = (get_coin).toLocaleString();
        document.cookie = `gift=${get_coin}; path=${location.pathname};expires=${new Date(+new Date()+31536000000).toString()}`;
        timeout = 600000;
        console.log(new Date,get_coin);
    }
    setTimeout(get_coins,timeout)
})()