Auto Loot

自动领取每日奖励

目前为 2021-01-14 提交的版本。查看 最新版本

// ==UserScript==
// @name         Auto Loot
// @namespace    https://blog.chrxw.com
// @version      0.3
// @description  自动领取每日奖励
// @author       Chr_
// @include      https://www.lootlink.me/*
// @grant        none
// ==/UserScript==

(function () {
    showLabel();
    dailyClaim();
})();


// 显示标签
function showLabel() {
    let uname = document.querySelector('#profileMenuInvoker>span');
    let tag = document.createElement('span');
    tag.textContent = ' (By Chr_) ';
    tag.addEventListener('click',()=>{
        window.open('https://blog.chrxw.com');
    });
    uname.appendChild(tag);
}

// 每日签到&自动开箱
function dailyClaim() {
    const MAX = 50;
    let tries = 0;
    clickDaily();
    retry(clickBox, 3000);
    function clickDaily() {
        let coin = document.querySelector('#wallet2 a[data-modal-target="#crate-modal"]');
        if (coin) {
            coin.click();
            retry(claimCoin, 1000);
        } else {
            retry(clickDaily, 500);
        }
    }    
    function clickBox() {
        let coin = document.querySelector('#wallet2 [src="/images/art/crate.png"]:not(.grayscale)');
        if (coin) {
            coin.click();
            retry(claimCoin, 1000);
        }  else {
            retry(clickBox, 500);
        }
    }
    function claimCoin() {
        let claimbtn = document.querySelector("#cratetab > a");
        if (claimbtn) {
            claimbtn.click();
            tries = 0;
            retry(closePanel, 1500);
        } else {
            retry(claimCoin, 500);
        }
    }
    function closePanel() {
        let title = document.querySelector("#cratetab > h4");
        if (title.textContent.search('Opened') != -1 || title.textContent.search('Received') != -1) {
            let closebtn = document.querySelector("#crate-modal > button");
            closebtn.click();
        } else {
            retry(closePanel, 500);
        }
    }

    function retry(foo, t) {
        console.log(foo.name);
        if (tries++ <= MAX) {
            setTimeout(() => {
                try {
                    foo();
                }
                catch (e) {
                    console.log(e);
                    throw e;
                }
            }, t);
        } else {
            log('操作超时');
        }
    }
}

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址