Twitch Auto-claim

Will auto-claim drops from campaigns

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Twitch Auto-claim
// @namespace    twitch-auto-drops
// @version      0.3
// @description  Will auto-claim drops from campaigns
// @author       PlatinumLyfe
// @run-at       document-idle
// @match        https://www.twitch.tv/drops/inventory
// @icon         https://static.twitchcdn.net/assets/favicon-16-52e571ffea063af7a7f4.png
// @grant        none
// ==/UserScript==

(function(window, document) {
    'use strict';

    const claimButtonSelector = '[data-test-selector="DropsCampaignInProgressRewardPresentation-claim-button"]';
    var timeMins = 2.5;
    var timeScale = 0.5;
    console.log('Script running and checking for claimable drops...');

    setTimeout(function () {

        var claimButton = document.querySelector(claimButtonSelector);
        if (claimButton) {
            console.log('Claim found!');
            claimButton.click();
        } else {
            console.info('No claimable items found... sorry');
        }
        console.log('Refreshing page in ' + timeMins + ' minutes');
        setInterval(function () {
            timeMins = timeMins - timeScale;
            console.log('Refreshing page in ' + timeMins + ' minutes');
            if (timeMins <= 0) window.top.location.reload();
        }, 1000 * 60 * timeScale);
    }, 5000);
    // Sometimes this bugs and won't reload. This should fix.
    setTimeout(window.top.location.reload, (1000 * 60 * timeMins) + 5000);
    setTimeout(window.location.reload, (1000 * 60 * timeMins) + 5000);
})(window, document);