Skip to content

Instantly share code, notes, and snippets.

@aqzlpm11
Created November 21, 2021 11:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aqzlpm11/e498d59d94983bdb4c50fb3a889c1577 to your computer and use it in GitHub Desktop.
Save aqzlpm11/e498d59d94983bdb4c50fb3a889c1577 to your computer and use it in GitHub Desktop.
油猴脚本:网络学堂 批改作业 跳转到下一个人
// ==UserScript==
// @name 网络学堂 批改作业 跳转到下一个人
// @namespace http://tampermonkey.net/
// @version 0.2
// @description try to take over the world!
// @author You
// @match https://learn.tsinghua.edu.cn/f/wlxt/kczy/xszy/teacher/beforePiYue?*
// @icon https://www.google.com/s2/favicons?domain=tsinghua.edu.cn
// @grant none
// ==/UserScript==
(function() {
'use strict';
document.goSubmit = goSubmit;
if (document.body.getInnerHTML().indexOf("服务器内部错误") != -1) {
alert("[插件提示]尝试跳到下一个学号。");
setTimeout(goNext, 500);
}
})();
function getQueryVariable(variable)
{
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if(pair[0] == variable){return pair[1];}
}
return(false);
}
async function goNext() {
const xszyid = getQueryVariable('xszyid')
const last_eight = xszyid.slice(xszyid.length-8, xszyid.length)
const max_retry = 100;
for (var i = 1; i <= max_retry; i++) {
const nxt_xszyid = xszyid.slice(0, xszyid.length-8) + (eval('0x'+last_eight)+i).toString(16)
const nxt_url = window.location.toString().replace(xszyid, nxt_xszyid)
var response = await fetch(nxt_url)
if (response.status == 200) {
window.location.href = nxt_url;
return;
}
}
alert("[插件提示]已经到底了,没有下一个学号了。");
}
function goSubmit() {
if (!$("#form_sn1").valid()) {
return;
}
MyApp.submitFileFormProgress(
'/b/wlxt/kczy/xszy/teacher/piYueSaveAndNext',
"form_sn1", function(data) {
MyApp.showResult(data, function() {
goNext();
// var tzurl = data.object; //跳转url
// var reg = new RegExp("amp;", "g");//g,表示全部替换。
// tzurl = tzurl.replace(reg, "");
// window.location.href = "" + tzurl;
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment