// ==UserScript== // @name 统一战线史网络知识竞赛 // @namespace nawlgzs@gmail.com // @version 1.0.0 // @description 统一战线史和《统一战线工作条例》网络知识竞赛,学油猴脚本来油猴中文网就对了。 // @author Ne-21 // @match *://*.hntv.tv/* // @connect api.gocos.cn // @run-at document-end // @grant unsafeWindow // @grant GM_xmlhttpRequest // @supportURL https://script.521daigua.cn/UserGuide/faq.html // @homepage https://script.521daigua.cn // @license MIT // ==/UserScript== var _w = unsafeWindow, _l = location, router, _host = "https://api.gocos.cn"; var t = setInterval(() => { router = document.querySelector('uni-app').__vue__.$router; if (typeof router != undefined) { clearInterval(t) init() } }, 1000) function init() { if (_l.pathname == '/total/tzdt/') { router.afterHooks.push(() => { console.log('Fuck Router!!!!!!!!') if (router.history.current.path.indexOf('answer/answer') != -1) { setTimeout(() => { let q = document.querySelector('body > uni-app > uni-page > uni-page-wrapper > uni-page-body > uni-view > uni-view.wrap-question > uni-view.u-text > uni-text > span').textContent getAnswer(q).then((res) => { let p = document.createElement("p"); p.style.color = "red"; p.textContent = "参考答案:" + res; document.querySelector('body > uni-app > uni-page > uni-page-wrapper > uni-page-body > uni-view > uni-view.wrap-question > uni-view.u-text > uni-text > span').appendChild(p); let as = document.querySelectorAll('body > uni-app > uni-page > uni-page-wrapper > uni-page-body > uni-view > uni-view.wrap-question > uni-view.wrap-question-list > uni-view') as.forEach((item) => { let a = item.textContent.replace(/^[A-Z]、/, '').trim() if (res.indexOf(a) != -1) { item.click() } }) let next = document.querySelector('body > uni-app > uni-page > uni-page-wrapper > uni-page-body > uni-view > uni-view.wrap-question > uni-button > uni-text') setTimeout(() => { next.click() }, 2000) }).catch((e) => { let p = document.createElement("p"); p.style.color = "red"; p.textContent = "参考答案:" + e; document.querySelector('body > uni-app > uni-page > uni-page-wrapper > uni-page-body > uni-view > uni-view.wrap-question > uni-view.u-text > uni-text > span').appendChild(p); }) }, 3000) } else if (router.history.current.path.indexOf('answerResult') != -1) { setTimeout(() => { document.querySelector('body > uni-app > uni-page > uni-page-wrapper > uni-page-body > uni-view > uni-view.wrap > uni-view > uni-view.wrap-content-bottom > uni-button > uni-text').click() }, 2000) } else { console.log(router.history.current.path) } }) } } function getAnswer(q) { return new Promise((resolve, reject) => { GM_xmlhttpRequest({ method: 'POST', url: _host + '/index.php/cxapi/hnzjjs/getanswer?v=2', data: 'q=' + q, headers: { "Content-Type": "application/x-www-form-urlencoded" }, onload: function (xhr) { let data = JSON.parse(xhr.responseText) if (data.code == 1) { resolve(data.data[0].a) } else { reject(data.msg) } } }) }) }