// ==UserScript== // @name 北理工乐学增强 // @namespace YinTianliang_i // @version 0.2 // @description 增强北理工乐学的功能 // @author Yin Tianliang // @include *//online.bit.edu.cn/moodle/course/view.php* // @grant none // @downloadURL none // ==/UserScript== /*jshint esversion: 6 */ problem_list = document.getElementsByClassName("activity programming modtype_programming"); if (!localStorage.AC) { window.localStorage.AC = ""; } for (let problem of problem_list) { let problem_id = problem.id.split("-")[1]; let dstDiv = problem.firstChild.firstChild.firstChild; //有些题目没有没对齐不能忍 if (dstDiv.className == "mod-indent") { dstDiv.className += " mod-indent-1"; } if (window.localStorage.AC.indexOf(problem_id) == -1) { $.post(`http://online.bit.edu.cn/moodle/mod/programming/result.php?id=${problem_id}`, null, res => { matches = res.match(/未能通过的有 *(\d)* *个/); if (matches) { if (matches[1] == "0") { window.localStorage.AC += "|" + problem_id; dstDiv.innerHTML = '
AC
'; } else { dstDiv.innerHTML = '
WA
'; } } }); } else { dstDiv.innerHTML = '
AC
'; } } // 增加 "自己的AC数" // 待优化 table = document.getElementsByClassName('generaltable')[1].children[1]; table.insertRow(0); table.children[0].insertCell(0); table.children[0].insertCell(1); table.children[0].insertCell(2); table.children[0].children[0].textContent = '0'; table.children[0].children[1].textContent = 'Your'; table.children[0].children[2].textContent = window.localStorage.AC.split('|').length;