-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.user.js
More file actions
127 lines (108 loc) · 4.81 KB
/
script.user.js
File metadata and controls
127 lines (108 loc) · 4.81 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
// ==UserScript==
// @name 移除超星鼠标监听
// @name:en Remove-ChaoXing-Listeners
// @version 1.0.0
// @description 屏蔽超星学习通页面的部分监听器
// @author uednd
// @homepage https://github.com/uednd/Remove-ChaoXing-Listeners
// @license MIT
// @match https://*.chaoxing.com/*
// @grant none
// @run-at document-start
// ==/UserScript==
(function() {
'use strict';
const CONFIG = {
enableDebugLog: false, // 启用调试日志
bypassMultiDeviceDetection: true // 屏蔽多开监测
};
function log(message, ...args) {
if (CONFIG.enableDebugLog) {
console.log(`[Remove-ChaoXing-Listeners] ${message}`, ...args);
}
}
function bypassMultiDeviceDetection() {
if (!CONFIG.bypassMultiDeviceDetection) return;
log('开始绕过多开检测');
const originalCreateElement = document.createElement.bind(document);
document.createElement = function(tagName) {
const element = originalCreateElement(tagName);
if (tagName && tagName.toLowerCase() === 'script') {
const originalSetAttribute = element.setAttribute.bind(element);
const originalGetAttribute = element.getAttribute.bind(element);
let actualSrc = null;
element.setAttribute = function(name, value) {
if (name === 'src' && typeof value === 'string') {
if (value.includes('detect.chaoxing.com/api/monitor')) {
log('已阻止多开检测请求:', value.substring(0, 100));
return;
}
}
return originalSetAttribute(name, value);
};
Object.defineProperty(element, 'src', {
set: function(value) {
if (typeof value === 'string' && value.includes('detect.chaoxing.com/api/monitor')) {
log('已阻止多开检测请求(src赋值):', value.substring(0, 100));
return;
}
actualSrc = value;
originalSetAttribute('src', value);
},
get: function() {
return actualSrc || originalGetAttribute('src') || '';
},
configurable: true,
enumerable: true
});
}
return element;
};
const originalSetInterval = window.setInterval;
window.setInterval = function(callback, delay, ...args) {
if (delay === 30000) {
const callbackStr = callback.toString();
if (callbackStr.includes('detect.chaoxing.com') ||
callbackStr.includes('monitor')) {
log('已阻止多开检测定时器');
return -1;
}
}
return originalSetInterval.call(this, callback, delay, ...args);
};
}
bypassMultiDeviceDetection();
const originalAddEventListener = EventTarget.prototype.addEventListener;
EventTarget.prototype.addEventListener = function(type, listener, options) {
if ((type === 'mouseout' || type === 'mouseover') &&
(this === document || this === window || this === document.documentElement || this === document.body)) {
log(`阻止添加 ${type} 监听器到:`, this.constructor.name);
return;
}
return originalAddEventListener.call(this, type, listener, options);
};
function removeExistingListeners(source = 'unknown') {
log(`移除监听器 (来源: ${source})`);
try {
if (document.onmouseout) document.onmouseout = null;
if (document.onmouseover) document.onmouseover = null;
if (window.onmouseout) window.onmouseout = null;
if (window.onmouseover) window.onmouseover = null;
if (document.documentElement) {
if (document.documentElement.onmouseout) document.documentElement.onmouseout = null;
if (document.documentElement.onmouseover) document.documentElement.onmouseover = null;
}
if (document.body) {
if (document.body.onmouseout) document.body.onmouseout = null;
if (document.body.onmouseover) document.body.onmouseover = null;
}
log('监听器移除完成');
} catch (error) {
console.error('[Remove-ChaoXing-Listeners] 移除监听器时出错:', error);
}
}
window.addEventListener('load', function() {
removeExistingListeners('load');
}, { once: true });
log('脚本已启动');
})();