This repository was archived by the owner on Apr 8, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathEduCoderPasteMan.user.js
More file actions
244 lines (197 loc) · 8.14 KB
/
EduCoderPasteMan.user.js
File metadata and controls
244 lines (197 loc) · 8.14 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
// ==UserScript==
// @name 头歌复制粘贴
// @name:en EduCoder Freedom Paste
// @description 用于解除头歌的关卡的复制粘贴。如要在私网/校内网启用,请手动编辑脚本,脚本内附有编辑说明。(目前公网不可用)
// @description Copy and paste for unlocking the level of the EduCoder. This script is only enabled on the public network EduCoder by default. If you want to enable it on the private network/school network EduCoder, please edit the script manually. Editing instructions are included in the script.
// @namespace https://bbs.tampermonkey.net.cn/
// @source https://github.com/gaobobo/EduCoderPasteMan
// @version 3.0.1
// @author Gao Shibo, Lydia
// @match https://vpn.zcst.edu.cn/*
// @match https://tg.zcst.edu.cn/*
// @match http://172.16.36.150/*
// @license MIT
// @grant GM_registerMenuCommand
// @grant GM_unregisterMenuCommand
// @grant GM_setValue
// @grant GM_getValue
// ==/UserScript==
// 按照第10行格式添加匹配的网址,使用*代替变化的部分。
// 例如第12行表示所有https://tg.zcst.edu.cn/XXXXXX的网址。
// 将其添加到第10行的@match下即可。
/**
* Pop up a flyout.
*
* @param {String} message Message Content.
* @param {int} showTime Show time(ms). -1 never close.
*/
function flyoutMessage (message, showTime) {
let flyoutMessageHTML = document.createElement("div");
if (document.getElementById("alersContainer") === null) {
flyoutMessageHTML.id = "alersContainer";
flyoutMessageHTML.style.position = "fixed";
flyoutMessageHTML.style.top = "8px";
flyoutMessageHTML.style.width = "100%";
flyoutMessageHTML.style.zIndex = "9999";
flyoutMessageHTML.style.margin = "10px auto";
flyoutMessageHTML.style.alignItems = "center";
flyoutMessageHTML.style.display = "flex";
flyoutMessageHTML.style.flexDirection = "column";
} else {
flyoutMessageHTML = document.getElementById("alersContainer");
}
const flyoutMessageHTML_content = document.createElement("span");
flyoutMessageHTML_content.style.margin = "5px"
flyoutMessageHTML_content.style.padding = "9px 12px";
flyoutMessageHTML_content.style.fontSize = "14px";
flyoutMessageHTML_content.style.backgroundColor = "white";
flyoutMessageHTML_content.style.borderRadius = "4px";
flyoutMessageHTML_content.style.boxShadow = "0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 9px 28px 8px rgba(0, 0, 0, 0.05)";
flyoutMessageHTML_content.style.width = "fit-content";
flyoutMessageHTML_content.innerText = message;
flyoutMessageHTML.appendChild(flyoutMessageHTML_content);
document.body.appendChild(flyoutMessageHTML);
if (showTime >= 0) {
setTimeout(function() {flyoutMessageHTML_content.remove();}, showTime);
}
}
/**
* Accelerate timer.
*
* @description NOTICE: must be used before the timer is created.
* @param {int} rate Timer acceleration rate. 0 stop Timer.
*/
function timerFaster (rate) {
let hookSetInterval = window.setInterval;
unsafeWindow.setInterval=function(a,b){
return hookSetInterval(a,rate === 0 ? 0 : b/rate);
}
}
/**
* Hook listeners to remove copy and paste restrictions.
*
* @returns {EventListener} Return the Listener object that hooked with remove() method.
*/
function hookListener () {
const Listener = EventTarget.prototype.addEventListener;
EventTarget.prototype.addEventListener=function (...args){
if (args.length != 0 && args[0] === "keydown" && args[1].name === "checkPaste") {
eventList[args[0]].push({
event: args[1],
remove: () => this.removeEventListener.apply(this,...args)
})
} else if (args.length != 0 && args[0] === "paste" && args[1].name === "checkPaste") {
eventList[args[0]].push({
event: args[1],
remove: () => this.removeEventListener.apply(this,...args)
}) }
else {
Listener.call(this,...args);
}
}
return Listener;
}
/**
* Check current page type.
*
* @returns {String} Return current page type, like "com.educoder.shixun.code". Return "com" for unknow page.
*/
function checkPage () {
if (document.getElementById("educoder") !== null) {
if (document.getElementsByClassName("monaco-aria-container").length > 0)
return "com.educoder.shixun.code";
else if (document.getElementsByClassName("vnc-panel animated fadeIn").length > 0)
return "com.educoder.shixun.linux"
else if (document.getElementsByClassName("xterm-screen").length > 0)
return "com.educoder.shixun.terminal"
else
return "com.educoder";
} else
return "com";
}
/**
* Initialize menu items
*
*/
function initializeMenu () {
if (GM_getValue("timerRate") === undefined || GM_getValue("timerRate") === -1) {
const menuItems = [
GM_registerMenuCommand(
"(beta)开启定时器加速-2X",
function () {
GM_setValue("timerRate",2);
menuItems.forEach(GM_unregisterMenuCommand);
initializeMenu();
flyoutMessage("定时器加速已开启。刷新页面后生效。", 5000);
}
),
GM_registerMenuCommand(
"(beta)开启定时器加速-20X",
function () {
GM_setValue("timerRate",20);
menuItems.forEach(GM_unregisterMenuCommand);
initializeMenu();
flyoutMessage("定时器加速已开启。刷新页面后生效。", 5000);
}
),
GM_registerMenuCommand(
"(beta)开启定时器加速-50X",
function () {
GM_setValue("timerRate",50);
menuItems.forEach(GM_unregisterMenuCommand);
initializeMenu();
flyoutMessage("定时器加速已开启。刷新页面后生效。", 5000);
}
),
GM_registerMenuCommand(
"(beta)开启定时器加速-500X",
function () {
GM_setValue("timerRate",500);
menuItems.forEach(GM_unregisterMenuCommand);
initializeMenu();
flyoutMessage("定时器加速已开启。刷新页面后生效。", 5000);
}
),
]
} else {
const menuItems = [
GM_registerMenuCommand(
"(beta)关闭定时器加速",
function () {
GM_setValue("timerRate",-1);
menuItems.forEach(GM_unregisterMenuCommand);
initializeMenu();
flyoutMessage("定时器加速已关闭。刷新页面后生效。", 5000);
}
)
]
}
}
/**
* Main function.
*
*/
(function() {
'use strict';
initializeMenu();
if (GM_getValue("timerRate") !== -1) {
timerFaster(GM_getValue("timerRate"));
GM_setValue("timerRate", -1);
flyoutMessage("定时器加速已开启。仅本次会话有效,刷新后将自动恢复。\n该功能为测试功能,由此引发的问题概不负责。", 5000);
}
let listenerPrepareRemove = hookListener();
setTimeout(function() {
if (checkPage() !== "com.educoder.shixun.code")
return;
listenerPrepareRemove.remove;
let messages = [
"✔️脚本已运行。你现在可以自由地复制粘贴了。",
"✔️已破解头歌的复制粘贴,Enjoy It !",
"✔️什么垃圾edocoder,monaco写的一坨💩",
"✔️FBI Warning⚠️⚠️⚠️! Already F***ed Educoder's ass! Damn!",
]
const randomIndex = Math.floor(Math.random() * Math.random() * messages.length);
messages = messages[randomIndex]
flyoutMessage(messages,5000);
},3000);
})();