dati

自动答题

目前為 2018-09-28 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name                dati
// @name:zh-CN          大头答题
// @namespace           www.icycat.com
// @description         自动答题
// @description:zh-CN   检测大仙答案自动答题
// @include             https://www.douyu.com/1209
// @version             1.0
// @run-at              document-end
// ==/UserScript==


var textTimer = setInterval(function() {
    textCheck();
}, 1000);

function go(index) {
    clearInterval(textTimer);
    var liArray = $("div[class^='answerProblem'] ul li");
    if (liArray.length > 0) {
        $(liArray[index - 1]).trigger('click');
        console.log('答题完成,19分钟后自动刷新网页');
        setTimeout(function() {
            window.location.reload();
        }, 1140000);
        return;
    }
    setTimeout(() => {
        go(index)
    }, 50);
}

function textCheck() {
    var user = $('[data-nn=37丶机器人]');
    if (user.length > 0) {
        var text = user[user.length - 1].parentNode.parentNode.querySelector('.chat-msg-item').innerText;
        text.substr(0, 1);
        console.log('检测到参考答案' + text.substr(0, 1));
        switch (text.substr(0, 1)) {
            case 'A':
                go(1);
                break;
            case 'B':
                go(2);
                break;
            case 'C':
                go(3);
                break;
        }
    }
}