Auto Loot

自动领取每日奖励

16.01.2021 itibariyledir. En son verisyonu görün.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

(Zateb bir user-style yöneticim var, yükleyeyim!)

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

(function () {
    'use strict';
    showLabel();
    dailyClaim();
    add10xBtn();
})();
// 显示标签
function showLabel() {
    let uname = document.querySelector('#profileMenuInvoker>span');
    let tag1 = document.createElement('span');
    tag1.textContent = ' (反馈 |';
    tag1.addEventListener('click', () => {
        window.open('https://keylol.com/t676764-1-1');
    });
    let tag2 = document.createElement('span');
    tag2.textContent = ' By Chr_) ';
    tag2.addEventListener('click', () => {
        window.open('https://blog.chrxw.com');
    });
    uname.appendChild(tag1);
    uname.appendChild(tag2);
}
// 每日签到&自动开箱
function dailyClaim() {
    const MAX = 20;
    let tries = 0;
    clickDaily();
    retry(() => { tries = 0; clickBox(); }, 3000);
    function clickDaily() {
        let coin = document.querySelector('#wallet2 a[data-modal-target="#crate-modal"]');
        if (coin) {
            coin.click();
            tries = 0;
            retry(claimCoin, 1000);
        } else {
            // retry(clickDaily, 500);
        }
    }
    function clickBox() {
        let coin = document.querySelector('#wallet2 div:not([style*="display:none"])>[src="/images/art/crate.png"]:not(.grayscale)');
        if (coin) {
            coin.parentElement.click();
            tries = 0;
            retry(claimCoin, 1000);
        } else {
            // retry(clickBox, 500);
        }
    }
    function claimCoin() {
        let claimbtn = document.querySelector("#cratetab > a");
        if (claimbtn) {
            claimbtn.click();
            tries = 0;
            retry(closePanel, 1000);
        } 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 {
            console.log('操作超时');
        }
    }
}
// 添加x连按钮
function add10xBtn() {
    let lootBtns = document.querySelectorAll('button[data-modal-target="#loot-modal"]');
    let i = 0;
    for (let lootBtn of lootBtns) {
        let bar = lootBtn.parentElement.parentElement;
        let btn10x = document.createElement('button');
        btn10x.id = 'loot10x' + (i).toString();
        btn10x.onclick = loot10x;
        btn10x.className = 'float-right btn btn-lg u-btn-cyan g-color-white u-btn-hover-v2-1';
        btn10x.textContent = '五连';
        bar.children[0].insertBefore(btn10x, bar.children[0].children[0]);
        i++;
    }
}
// 五连
function loot10x(e) {
    const MAX = 50;
    const LOOT = 5;
    let tries = 0;
    let count = 0;
    clickLoot();
    function clickLoot() {
        let t = e.originalTarget.id.match(/^loot10x(\d+)$/);
        t = t ? t[1] : 0;
        let lootBtns = document.querySelectorAll('button[data-modal-target="#loot-modal"]');
        if (lootBtns == null) {
            alert('未找到Loot按钮');
            return;
        }
        let lootBtn = lootBtns[Number(t)]
        lootBtn.click();
        tries = 0;
        retry(claimLoot, 1000);
    }
    function claimLoot() {
        let lootbtn = document.querySelector('#rollit');
        if (lootbtn) {
            document.getElementById('rollmessage').textContent = '当前第' + (count + 1).toString() + '抽';
            lootbtn.click();
            tries = 0;
            retry(waitLoot, 1000);
        } else {
            retry(claimLoot, 1000);
        }
    }
    function waitLoot() {
        let lootbtn = document.querySelector("#rollit");
        if (lootbtn.textContent.search('Try') != -1) {
            if (++count >= LOOT) { console.log('done'); return; }// 10连抽完结束
            tries = 0;
            retry(claimLoot, 1000);
        } else {
            retry(waitLoot, 1000);
        }
    }
    function retry(foo, t) {
        console.log(foo.name);
        if (tries++ <= MAX) {
            setTimeout(() => {
                try {
                    if (document.getElementById('rolltab') == null) {
                        console.log('cancel');
                        return;
                    }
                    foo();
                }
                catch (e) {
                    console.log(e);
                    throw e;
                }
            }, t);
        } else {
            console.log('操作超时');
        }
    }

}