ICVE 考试助手引用库

动态替换在线用户查询接口

Versione datata 06/06/2020. Vedi la nuova versione l'ultima versione.

Questo script non dovrebbe essere installato direttamente. È una libreria per altri script da includere con la chiave // @require https://update.greasyfork.org/scripts/404781/813146/ICVE%20%E8%80%83%E8%AF%95%E5%8A%A9%E6%89%8B%E5%BC%95%E7%94%A8%E5%BA%93.js

function encode(s) {
    var i, r = [], c, x;
    for (i = 0; i < s.length; i++)
        if ((c = s.charCodeAt(i)) < 0x80) r.push(c);
        else if (c < 0x800) r.push(0xC0 + (c >> 6 & 0x1F), 0x80 + (c & 0x3F));
        else {
            if ((x = c ^ 0xD800) >> 10 == 0)
                c = (x << 10) + (s.charCodeAt(++i) ^ 0xDC00) + 0x10000,
                    r.push(0xF0 + (c >> 18 & 0x7), 0x80 + (c >> 12 & 0x3F));
            else r.push(0xE0 + (c >> 12 & 0xF));
            r.push(0x80 + (c >> 6 & 0x3F), 0x80 + (c & 0x3F));
        };
    return r;
}

function token(s) {
    var data = new Uint8Array(encode(s))
    var i, j, t;
    var l = ((data.length + 8) >>> 6 << 4) + 16, s = new Uint8Array(l << 2);
    s.set(new Uint8Array(data.buffer)), s = new Uint32Array(s.buffer);
    for (t = new DataView(s.buffer), i = 0; i < l; i++)s[i] = t.getUint32(i << 2);
    s[data.length >> 2] |= 0x80 << (24 - (data.length & 3) * 8);
    s[l - 1] = data.length << 3;
    var w = [], f = [
        function () { return m[1] & m[2] | ~m[1] & m[3]; },
        function () { return m[1] ^ m[2] ^ m[3]; },
        function () { return m[1] & m[2] | m[1] & m[3] | m[2] & m[3]; },
        function () { return m[1] ^ m[2] ^ m[3]; }
    ], rol = function (n, c) { return n << c | n >>> (32 - c); },
        k = [1518500249, 1859775393, -1894007588, -899497514],
        m = [1732584193, -271733879, null, null, -1009589776];
    m[2] = ~m[0], m[3] = ~m[1];
    for (i = 0; i < s.length; i += 16) {
        var o = m.slice(0);
        for (j = 0; j < 80; j++)
            w[j] = j < 16 ? s[i + j] : rol(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1),
                t = rol(m[0], 5) + f[j / 20 | 0]() + m[4] + w[j] + k[j / 20 | 0] | 0,
                m[1] = rol(m[1], 30), m.pop(), m.unshift(t);
        for (j = 0; j < 5; j++)m[j] = m[j] + o[j] | 0;
    };
    t = new DataView(new Uint32Array(m).buffer);
    for (var i = 0; i < 5; i++)m[i] = t.getUint32(i << 2);

    var hex = Array.prototype.map.call(new Uint8Array(new Uint32Array(m).buffer), function (e) {
        return (e < 16 ? "0" : "") + e.toString(16);
    }).join("");
    return hex;
}

async function apiAnswer(q) {
    const _list = []
    let a1 = requestAPI('GET', `http://www.mt3e.cn/api1.php?question=${encodeURIComponent(q)}`)
    let a3 = requestAPI('GET', `http://www.mt3e.cn/api2.php?question=${encodeURIComponent(q)}`)
    let a2 = requestAPI('GET', `http://www.mt3e.cn/api3.php?question=${encodeURIComponent(q)}`)
    alert("接口响应缓慢,耐心等待几秒")
    try {
        let results = await Promise.all([a1, a2, a3])
        results.forEach(e => {
            if (e.responseText) {
                const submitBody = {
                    _id: '',
                    q: '',
                    a: [],
                    o: [],
                    t: -1,
                    s: ""
                }
                try {
                    console.log(e.responseText);
                    const json = JSON.parse(e.responseText)
                    if (json.answer.indexOf("抱歉找不到结果,") == -1 && json.answer != "暂无答案") {
                        submitBody._id = token(new Date().getTime()) + "" + rnd(100, 100000)
                        submitBody.q = json.question
                        submitBody.a.push(json.answer)
                        _list.push(submitBody)
                    }
                } catch (e) {
                    console.log(e);
                }

            }
            //todo 需提交
            // else if (url.match(/.*api\/tmlib/)) {
            // } else if (url.match(/.*api\/morepng/)) {
            // } else if (url.match(/.*\/fortest/)) {
            // }
        })
        console.log(_list);

        if (_list.length != 0)
            requestAPI("PUT", "http://39.96.64.75/s", {
                headers: { "Content-Type": "application/json;charset=utf-8" },
                data: JSON.stringify(_list)
            })
        return _list.map(e => {
            return {
                'question': e.q,
                'answer': e.a,
                'options': e.o,
            }
        })
    } catch (e) {
        console.log(e);
        return [{
            'question': "未搜索到答案或接口出现问题",
            'answer': "如果您是购买使用,请举报售卖方,本脚本完全免费开源使用",
            'options': "请自行修改接口或联系作者",
        }]
    }

}