8种机械键盘轴体对比
本人程序员,要买一个写代码的键盘,请问红轴和茶轴怎么选?
抢课脚本
本文档脚本内容适用于USTC研究生选课系统
如下文所说,你需要指定自己想选的课程号,并可以修改你想要的每次查询时间间隔
方法1 浏览器console
此方法需要每次打开选课主页手动粘贴运行脚本
Chrome下,F12快捷键打开开发者工具
点击上方Console进入控制面板(如上图红圈)
确认当前在top域(如上图红圈),在console中粘贴如下代码,并按回车:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45var ids = ["CH6520501", "CH6620401", "CH2522301"];
var times = 5000;
var got = [];
for (var i = 0; i < ids.length; i++) {
got.push(false);
}
var inter = setInterval(function(){
var log_string = "";
var table = frames["mainFrame"].frames["I2"].frames["xkpFrame"].document.children[0].children[1].children[0].children[0].children[2].children[0];
for (var i = 0; i < ids.length; i++) {
var line = get_line_with_id(table, ids[i]);
var people = line.children[8];
if (got[i] === false) {
if (people.childNodes[0].data != (people.childNodes[3].innerText + "/")) {
frames["mainFrame"].frames["I2"].frames["xkpFrame"].xk(ids[i]);
got[i] = true;
alert("class" + toString(i) + " get!");
} else {
log_string = log_string + line.children[3].children[0].innerText + " : " + people.childNodes[0].data + people.childNodes[3].innerText + "n";
}
}
}
for (var i = 0; i < got.length; i++) {
if (got[i] === false) {
console.log(log_string);
frames["mainFrame"].frames["I2"].frames["xkpFrame"].cxdxkc();
return;
}
}
clearInterval(inter);
alert("all get!");
return;
}, times);
function (table, id){
for (i = 1; i < table.rows.length; i++) {
if (table.rows[i].children[2].innerText == id) {
return table.rows[i];
}
}
return null;
}
每查询一次,脚本将在console中输出当次查询的人数结果:
若你不想有这样的输出,将上图中Default levels中的Info取消勾选
当你想结束查询时,请刷新选课接口
方法2 使用插件Tampermonkey
此方法可以自动在选课页面打开时进行刷课,无需人工干预
在Chrome扩展商店中搜索Tampermonkey并安装,安装完成后在Chrome地址栏右侧将出现该扩展的图标:
点击该图标,并选择添加新脚本,进入下图接口
你可以:将上文中的代码粘贴到图中// Your code here...的位置,并用选课网页地址替换掉图中match之后的http开头的内容
(推荐)将编辑区中所有内容清除,替换为下文内容:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59// @name yanjiusheng
// @namespace http://tampermonkey.net/
// @version 1.1
// @description multiple classes supported
// @author Jeffery
// @match http://mis.teach.ustc.edu.cn/gradLoginSuc.do
// @grant none
// ==/UserScript==
(function(){
;
//在这里添加你想要的课程号们,不限制个数
var ids = ["CH6520501", "CH6620401", "CH2522301"];
//在这里修改每多久查询一次,单位毫秒。不要过于频繁以免被服务器封禁。原为5000。
var times = 5000;
var got = [];
for (var i = 0; i < ids.length; i++) {
got.push(false);
}
var inter = setInterval(function(){
var log_string = "";
var table = frames["mainFrame"].frames["I2"].frames["xkpFrame"].document.children[0].children[1].children[0].children[0].children[2].children[0];
for (var i = 0; i < ids.length; i++) {
var line = get_line_with_id(table, ids[i]);
var people = line.children[8];
if (got[i] === false) {
if (people.childNodes[0].data != (people.childNodes[3].innerText + "/")) {
frames["mainFrame"].frames["I2"].frames["xkpFrame"].xk(ids[i]);
got[i] = true;
alert("class" + toString(i) + " get!");
} else {
log_string = log_string + line.children[3].children[0].innerText + " : " + people.childNodes[0].data + people.childNodes[3].innerText + "n";
//console.log(line.children[3].children[0].innerText + " : " + people.childNodes[0].data + people.childNodes[3].innerText);
}
}
}
for (var i = 0; i < got.length; i++) {
if (got[i] === false) {
console.log(log_string);
frames["mainFrame"].frames["I2"].frames["xkpFrame"].cxdxkc();
return;
}
}
clearInterval(inter);
alert("all get!");
return;
}, times);
function get_line_with_id(table, id){
for (i = 1; i < table.rows.length; i++) {
if (table.rows[i].children[2].innerText == id) {
return table.rows[i];
}
}
return null;
}
// Your code here...
})();
点击保存按钮
启用脚本方法:打开选课标签页
点击Tampermonkey扩展按钮,将出现当前脚本的开关
打开该开关,并刷新选课页面(刷新后才开启生效),若观察到隔指定时间(5000ms)页面自动查询,或在Chrome console看到课程人数的输出并且前缀数字增加,则为开启成功:
Tip: 你可以选择开课单位,以减少每次查找的流量、时间开销
关闭脚本方法:同启用脚本的方法,仅将打开开关改为关闭开关。别忘了刷新页面!
Note:如果你有旧的抢课脚本,请在开启脚本的小弹窗关闭它并保持关闭,或在Tampermonkey管理面板永久删除它: