Greasy Fork

Greasy Fork is available in English.

Auto Claim Twitch drop(CN only)

Auto clicking "claim" near the chat really

当前为 2022-06-12 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Auto Claim Twitch drop(CN only)
// @version      0.4
// @description  Auto clicking "claim" near the chat really
// @author       eebssk1
// @match        https://www.twitch.tv/*
// @run-at       document-end
// @license      MPL
// @namespace    CN_only
// ==/UserScript==

function time() {
    const today = new Date();
    const date = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate();
    const time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
    const dateTime = date+' '+time;
    return dateTime
}

function close() {
  let button = document.querySelector('button[aria-label="关闭"]');
  if(button != null)
    button.click();
}

function main() {
    let done = false;
    let button = document.querySelector('button[aria-label="领取奖励"]');
    let button2 = null;
    let oblist = document.querySelectorAll('div[data-a-target="tw-core-button-label-text"]');
    for(let a of oblist ){
      if(a.innerText === "领取")
         button2 = a.parentElement.parentElement;
    }
    if(button != null){
        button.click();
        console.log('Clicked at '+ time());
        done = true;
    }
    if(button2 != null){
        button2.click();
        console.log('Clicked at '+ time());
        done = true;
    }
   if(done){
        setTimeout(close,1000);
        setTimeout(function(){ location.reload(); }, 2000);
   }
}

function mainfr() {
    setTimeout(main,1000);
}

const observer = new MutationObserver(mainfr);
observer.observe(document.body, {childList: true, subtree: true});