您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
从数据库提取答案, 保存写过的题目答案,并自动填写。
当前为
// ==UserScript== // @name 浙江理工大学体育理论考试辅助脚本-自动作答、记录、恢复-SL大法好 // @namespace https://eliotzhang.cn // @homepage https://eliotzhang.cn // @version 2.0 // @description 从数据库提取答案, 保存写过的题目答案,并自动填写。 // @author EliotZhang // @match http://tygl.zstu.edu.cn/* // @run-at document-end // ==/UserScript== (function () { 'use strict'; let EZ = '------浙理体育脚本 by EliotZhang------\n' var titles = null var length = 0 function get_ans(k) { var st = titles[k].nextSibling.nextSibling var ans = '' while (st.style.length > 0) { if (st.firstChild.firstChild.checked) { ans = st.firstChild.firstChild.nextSibling.data.substr(2) break } st = st.nextSibling } return ans } function set_ans(k, ans) { var st = titles[k].nextSibling.nextSibling while (st.style.length > 0) { if (st.firstChild.firstChild.nextSibling.data.substr(2) === ans) { st.firstChild.firstChild.checked = true break } st = st.nextSibling } } function saveAns() { for (var i = 0; i < length; ++i) { var ans = get_ans(i) if (ans != '' && ans != undefined) { window.localStorage.setItem(titles[i].text, ans) } } } function loadAns() { for (var i = 0; i < length; ++i) { var ans = window.localStorage.getItem(titles[i].text) if (ans != null && ans != 'undefined') { set_ans(i, ans) } } } function getAns() { $.get("https://1-1302682750.cos.ap-nanjing.myqcloud.com/yooc/tytk.json",data=>{ let voidAns=0; for(let x of $('a[id$="_title"]')){ if(data[x.innerText.trim()]==undefined){ voidAns++; let redtext=document.createAttribute("style"); redtext.nodeValue="color: red;"; x.attributes.setNamedItem(redtext); continue; } let y=x.nextElementSibling.nextElementSibling; let choice=0; let hasChoice=false; while(y.tagName==='P'){ if(data[x.innerText.trim()]===y.innerText.trim().substr(2)){ hasChoice=true; break; } choice++; y=y.nextElementSibling; } if(hasChoice){ $('input[name='+x.id.split('_')[0]+']')[choice].click() }else{ voidAns++; let redtext=document.createAttribute("style"); redtext.nodeValue="color: red;"; x.attributes.setNamedItem(redtext); } }; if(voidAns){ alert("有"+voidAns+"个题目未查询到答案!"); }else{ alert("答题完成!"); } }); } function main() { titles = $('a[id]') length = titles.length console.log(EZ, length) if (length <= 0) { return } getAns() setInterval(saveAns, 5000) setTimeout(loadAns, 5000) } // Your code here... setTimeout(main, 5000) })();