Auto Claim Twitch drop (beta)

Auto Claim Twitch drop in inventory

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==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);
})();