-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathloltronclass.js
140 lines (127 loc) · 2.76 KB
/
loltronclass.js
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
// ==UserScript==
// @name lol tronclass
// @namespace no
// @version 0.3
// @description lol teacher
// @author lol
// @match https://eclass.yuntech.edu.tw/course/*
// @match https://eclass.yuntech.edu.tw/exam/*
// @match https://tronclass.com.tw/course/*
// @match https://tronclass.com.tw/exam/*
// @match https://elearning.yuntech.edu.tw/learn/exam/*
// @icon https://media.discordapp.net/attachments/922733774633050112/969011518861623376/256.png
// @grant none
// @license MIT
// ==/UserScript==
var css = document.createElement('style')
var head = document.head
css.type = 'text/css'
css.innerText = `* {
-webkit-user-select: text !important;
-moz-user-select: text !important;
-ms-user-select: text !important;
user-select: text !important;
}`
;[].forEach.call(
[
'visibilitychange',
'webkitvisibilitychange',
'blur',
'mozvisibilitychange',
'msvisibilitychange',
'fullscreenElement',
'fullscreenEnabled',
'mozFullScreenEnabled',
'webkitFullscreenEnabled',
'msFullscreenEnabled',
'webkitIsFullScreen'
],
function (event_name) {
window.addEventListener(
event_name,
function (event) {
if (
event.type.includes('visibility') ||
event.type.includes('fullscreen') ||
event.type === 'blur'
) {
event.stopImmediatePropagation()
}
},
true
)
}
)
;[].forEach.call(
[
'contextmenu',
'copy',
'cut',
'paste',
'mouseup',
'mousedown',
'keyup',
'keydown',
'drag',
'dragstart',
'select',
'selectstart'
],
function (event) {
document.addEventListener(
event,
function (e) {
e.stopPropagation()
},
true
)
}
)
;[].forEach.call(['cut', 'paste', 'select', 'selectstart'], function (event) {
document.addEventListener(
event,
function (e) {
e.stopPropagation()
},
true
)
})
document.addEventListener(
'copy',
function (e) {
e.preventDefault()
e.stopPropagation()
try {
let copiedText = window.getSelection().toString()
console.log('In text:', copiedText)
let formattedText = copiedText
.replace(/\(\d+\s*分\)/g, '')
.replace(/[\t ]+/g, ' ')
.replace(/\n\s*\n/g, '\n')
.replace(/([A-D])\s*\.\s*([^\n]*)/g, '$1.$2')
.split('\n')
.map((line) => line.trim())
.filter((line) => line)
.join('\n')
.trim()
console.log('Out text:', formattedText)
e.clipboardData.setData('text/plain', formattedText)
} catch (error) {
console.error('Copy formatting error:', error)
}
},
{
capture: true
}
)
document.oncopy = null
document.onselectstart = null
document.oncontextmenu = null
window.addEventListener(
'load',
function () {
document.getElementById('Symbol(water-mark)').style.background = ''
},
false
)
head.appendChild(css)