Greasy Fork

Greasy Fork is available in English.

斗鱼助手

自动领取鱼丸(需要手动输入验证码)、自动打开宝箱

当前为 2018-12-10 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         斗鱼助手
// @namespace    https://github.com/EternalPhane/UserScripts/
// @version      0.5.1
// @description  自动领取鱼丸(需要手动输入验证码)、自动打开宝箱
// @author       EternalPhane
// @include      /^https?:\/\/(www|yuxiu)\.douyu\.com\/(topic\/)?\w+$/
// @resource     css https://raw.githubusercontent.com/EternalPhane/UserScripts/master/Douyu%20Assistant/douyu-assistant.css
// @resource     html https://raw.githubusercontent.com/EternalPhane/UserScripts/master/Douyu%20Assistant/douyu-assistant.html
// @require      https://code.jquery.com/jquery-3.3.1.min.js
// @grant        GM_addStyle
// @grant        GM_getResourceText
// ==/UserScript==

$.noConflict();
(($) => {
    'use strict';
    const attach = () => {
        GM_addStyle(GM_getResourceText('css'));
        $('div.ToolbarActivityArea').after(GM_getResourceText('html'));
        let chestId = null;
        let yuwanId = null;
        const getYuwan = () => {
            const time = $('span.RewardModule-countdown').text();
            const wait = () => {
                if ($('div.geetest_wait').length) {
                    $('div.geetest_btn')
                        .mouseenter()
                        .click();
                    getYuwan();
                } else {
                    setTimeout(wait, 100);
                }
            };
            switch (time) {
                case '领 取':
                    if ($('div.geetest_holder:visible').length) {
                        break;
                    }
                    if (!$('div.RewardModal.super').length) {
                        $('div.RewardModule-toggle')
                            .mouseenter()
                            .click()
                    };
                    $('span.RewardM-text.enable')
                        .mouseenter()
                        .click();
                    setTimeout(wait, 100);
                    return;
                case '完 成':
                    return;
                case '':
                    break;
                default:
                    const [minute, second] = time.split(':');
                    const ms = (Number(minute) * 60 + Number(second)) * 1000;
                    yuwanId = setTimeout(getYuwan, ms);
                    return;
            }
            yuwanId = setTimeout(getYuwan, 1000);
        };
        $('input#chest-switch').change((e) => {
            localStorage.setItem('chest', String(e.currentTarget.checked));
            e.currentTarget.checked
                ? (chestId = setInterval(() => {
                    if ($('div.TreasureGee:visible').length) {
                        return;
                    }
                    const treasure = $('div.Treasure.is-finish');
                    treasure.length && '领取' === treasure.find('div.TreasureStatus.is-open').text() && treasure.mouseenter().click();
                }, 100))
                : clearInterval(chestId);
        });
        $('input#yuwan-switch').change(
            (e) => {
                localStorage.setItem('yuwan', String(e.currentTarget.checked));
                e.currentTarget.checked ? getYuwan() : clearTimeout(yuwanId);
            }
        );
        $('input#chest-switch').prop('checked', 'true' == localStorage.getItem('chest')).change();
        $('input#yuwan-switch').prop('checked', 'true' == localStorage.getItem('yuwan')).change();
    };
    const wait = setInterval(() => {
        if ($('div.ToolbarActivityArea').length) {
            clearInterval(wait);
            attach();
        }
    }, 100);
})(jQuery);