Twitch 自動領取掉寶

Twitch 自動收取 [掉寶/Drops] , 簡易自訂設置 (優化版)

目前為 2023-09-08 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 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 Receive Drops
// @name:zh-TW          Twitch 自動領取掉寶
// @name:zh-CN          Twitch 自动领取掉宝
// @name:en             Twitch Auto Receive Drops
// @version             0.0.2
// @author              HentaiSaru
// @description         Twitch 自動收取 [掉寶/Drops] , 簡易自訂設置 (優化版)
// @description:zh-TW   Twitch 自動收取 [掉寶/Drops] , 簡易自訂設置 (優化版)
// @description:zh-CN   Twitch 自动收取 [掉宝/Drops] , 简易自定义设置 (优化版)
// @description:en      Twitch Auto Receive Drops, Easy Custom Settings (Optimized Version)

// @match        https://www.twitch.tv/drops/inventory
// @icon         https://cdn-icons-png.flaticon.com/512/8214/8214044.png

// @license      MIT
// @namespace    https://greasyfork.org/users/989635

// @run-at       document-end
// ==/UserScript==

(function() {
    var Withdraw, title;
    /* 配置設定 */
    const config = {
        ProgressBar: "p.CoreText-sc-1txzju1-0.egOfyN span.CoreText-sc-1txzju1-0",
        Checkbutton: "button.ScCoreButton-sc-ocjdkq-0.ScCoreButtonPrimary-sc-ocjdkq-1",
        CheckInterval: 120, // 檢查間隔 (seconds / 秒數)
        ProgressDisplay: true // 在標題展示進度

    }, observer = new MutationObserver(() => {
        Withdraw = document.querySelector(config.Checkbutton);
        Withdraw ? (observer.disconnect(), Withdraw.click()) : null;

        if (config.ProgressDisplay) {
            title = `${document.querySelector(config.ProgressBar).textContent}%`;
            title !== null ? document.title = title : null;
        }
    });
    observer.observe(document.body, {childList: true, subtree: true});
    setInterval(()=> {location.reload()}, 1000 * config.CheckInterval);
})();