Skip to content

Instantly share code, notes, and snippets.

@leoleoasd
Last active November 23, 2020 13:47
Show Gist options
  • Save leoleoasd/c8bddaeb15be9c8088a788e19d17e1af to your computer and use it in GitHub Desktop.
Save leoleoasd/c8bddaeb15be9c8088a788e19d17e1af to your computer and use it in GitHub Desktop.
课堂派增强
// ==UserScript==
// @name 课堂派快捷键
// @namespace http://leoleoasd.me/
// @version 0.1
// @description 给课堂派的判作业界面增加快捷键.
// @author Leo
// @match https://www.ketangpai.com/Review/file/homeworkid/*
// @grant none
// ==/UserScript==
/*
默认的快捷键:
c 对勾
x 叉
h 半对
q 问号
b 笔刷
a 箭头
t 矩形
e 椭圆
n 标注
u 下划线
d 删除线
l 高亮
*/
(function() {
'use strict';
document.querySelector("#pdfview").onload = function(e){
console.log("Leo script loaded!");
document.querySelector("#pdfview").contentWindow.document.addEventListener("keyup", function(e) {
switch(e.key){
case "c": // correct
document.querySelector("#dagou").click();
break;
case "x": // x
document.querySelector("#dacha").click();
break;
case "h": // half-correct
document.querySelector("#righterror").click();
break;
case "q": // question
document.querySelector("#doubt").click();
break;
case "b": // brush
document.querySelector("#tuya").click();
break;
case "a": // arrow
document.querySelector("#arrow").click();
break;
case "t": // rectangle
document.querySelector("#rectangle").click();
break;
case "e": // ellipse
document.querySelector("#ellipse").click();
break;
case "n": // 标注
document.querySelector("#pizhu").click();
break;
case "u": // under 下划线
document.querySelector("#xiahuaxian").click();
break;
case "d": // delete 删除线
document.querySelector("#shanchuxian").click();
break;
case "l": // light
document.querySelector("#huang").click();
break;
}
});
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment