您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Automatically click channel points bonus button
当前为
// ==UserScript== // @name Twitch Channel Points Chest Auto Opener // @name:ja Twitchポイントチェスト自動開封 // @version 1.01 // @author N.Y.Boyu // @description Automatically click channel points bonus button // @description:ja 自動でチャンネルポイントのボーナスボタンをクリックします // @match https://www.twitch.tv/* // @match https://dashboard.twitch.tv/* // @license MIT // @grant none // @namespace https://greasyfork.org/users/175598 // ==/UserScript== (function(){ if(MutationObserver&&history.pushState)console.log("CAO: Chest Auto Opener is enabled.");else return; const INITIAL_STANDBY=10000; //default: 10,000ms const INITIAL_RECALL=300000; //default: 300,000ms const CHEST_WAIT=895000; //default: 895,000ms //NOTE: Chest appears each 15 minutes. (help.twitch.tv/s/article/channel-points-guide) //avoid multi-thread let timer=-1; let setTimer=function(func,wait){ clearTimeout(timer); timer=setTimeout(func,wait); }; let container; let waiting=false; let check=function(){ if(waiting)return; let bonus = container.getElementsByClassName("claimable-bonus__icon")[0]; if(bonus){ bonus.click(); console.log("CAO: Chest opened at "+new Date()); waiting=true; setTimer(function(){waiting=false;check();},CHEST_WAIT); } }; let observer=new MutationObserver(check); let initCheck=function(){ container=document.getElementsByClassName("community-points-summary")[0]; if(container){ console.log("CAO: Channel points exist"); observer.observe(container,{childList:true,subtree:true}); check(); }else{ console.log("CAO: Channel points dosen't exist"); if(INITIAL_RECALL>0)setTimer(initCheck,INITIAL_RECALL); } }; //detect loaction change let init=function(){ console.log("CAO: location change detected at "+new Date()); waiting=false; observer.disconnect(); setTimer(initCheck,INITIAL_STANDBY); }; history.pushState=(f=>function(){let res=f.apply(this,arguments);init();return res;})(history.pushState); history.replaceState=(f=>function(){let res=f.apply(this,arguments);init();return res;})(history.replaceState); window.addEventListener('popstate',init); init(); })();