// ==UserScript== // @name 上海国家会计学院远程教育网题库收集脚本 // @namespace http://tampermonkey.net/ // @version 0.1 // @description 练习中心-课程练习,单独打开页面,每个课程自动收录10次题库,收录完毕自动关闭页面,收录结果在脚本存储中查看 // @author DreamNya // @match http://exercise.ce.esnai.net/default.aspx?controller=Home&action=SubjectByCourse&groupcode=accshanghai&* // @grant GM_setValue // @grant GM_getValue // @run-at document-end // ==/UserScript== //let iframe=unsafeWindow.document.querySelector('#frmMain').contentDocument; const $ = unsafeWindow.jQuery; const tittle = $('.font-brown').text(); //课程名称 let times = GM_getValue(tittle, 0); $('[answer]').each(function (index) { const arr = $(this).text().trim().replaceAll(" ", "").split('\n') const id = arr[0] if (GM_getValue(id)) return;//已收录过则跳过 const question = arr[4].replace(new RegExp('^' + (index + 1)), '') const choice = arr[5] const answer = (arr[6] == "查看答案" ? arr[10] : arr[9]).match(/A|B|C|D/g).map(i => choice.match(new RegExp(i + ".*?(?=(B|C|D|$))", "g"))).join('\n') GM_setValue(id, [question, answer]) //收录题库 }); GM_setValue(tittle, ++times);//记录收录次数 if (times > 10) { //收录10次 close() //关闭页面 } else { location.href = location.href //刷新页面 }