Auto Loot

自动领取每日奖励

Από την 14/01/2021. Δείτε την τελευταία έκδοση.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==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('操作超时');
        }
    }
}