Auto Claim Twitch drop (beta)

Auto Claim Twitch drop in inventory

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램을 설치해야 합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name            Auto Claim Twitch drop (beta)
// @name:de         Twitch-Drops automatisch abholen (beta)
// @name:fr         Récupération automatique des drops Twitch (beta)
// @name:es         Reclamación automática de drops de Twitch (beta)
// @name:it         Riscossione automatica dei drop di Twitch (beta)
// @name:pt         Resgate automático de drops da Twitch (beta)
// @name:ru         Автоматическое получение дропов Twitch (beta)
// @name:ja         Twitchドロップの自動受け取り (beta)
// @name:zh         自动领取 Twitch 掉落 (beta)
// @description     Auto Claim Twitch drop in inventory
// @description:de  Holt Twitch-Drops automatisch im Inventar ab.
// @description:fr  Récupérez automatiquement les drops Twitch dans l'inventaire.
// @description:es  Reclama automáticamente los drops de Twitch en el inventario.
// @description:it  Riscatta automaticamente i drop di Twitch nell'inventario.
// @description:pt  Resgate automaticamente os drops da Twitch no inventário.
// @description:ru  Автоматически получайте дропы Twitch в инвентаре.
// @description:ja  インベントリ内のTwitchドロップを自動的に受け取ります。
// @description:zh  自动领取库存中的 Twitch 掉落。
// @version         0.0.4 beta
// @author          Wack.3gp (https://greatest.deepsurf.us/users/4792)
// @copyright       2023+, Wack.3gp
// @namespace       https://greatest.deepsurf.us/users/4792
// @license         CC BY-NC-SA-4.0; https://creativecommons.org/licenses/by-nc-sa/4.0/
// @icon            https://static.twitchcdn.net/assets/favicon-32-e29e246c157142c94346.png
//
// @include         *twitch.tv/drops/inventory*
// @run-at          document-end
// @grant           none
//
// @supportURL      https://greatest.deepsurf.us/scripts/448887/feedback
// @compatible      Chrome tested with Tampermonkey
// @contributionURL https://www.paypal.com/donate/?hosted_button_id=BYW9D395KJWZ2
// @contributionAmount €1.00
// ==/UserScript==

/* jshint esversion: 9 */

(function() {
    'use strict';

    const claimButtonSelector = '[data-test-selector="DropsCampaignInProgressRewardPresentation-claim-button"]';
    let isProcessing = false;

    const claimDrop = () => {
        if (isProcessing) return;

        const btn = document.querySelector(claimButtonSelector);
        if (btn) {
            isProcessing = true;
            btn.click();
            
            setTimeout(() => {
                location.reload();
            }, 2000);
        }
    };

    const observer = new MutationObserver(() => {
        claimDrop();
    });

    observer.observe(document.body, {
        childList: true,
        subtree: true
    });

    claimDrop();

    setInterval(function() {
        window.location.reload();
    }, 300000);
})();