-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinject.js
More file actions
55 lines (50 loc) · 1.92 KB
/
Copy pathinject.js
File metadata and controls
55 lines (50 loc) · 1.92 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
(function () {
const script = document.currentScript;
const mode = script?.dataset?.mode || "all";
const revoltzState = window.__revoltzUnprotectState || (window.__revoltzUnprotectState = {});
if (mode === "all" || mode === "rightclick") {
document.oncontextmenu = null;
window.oncontextmenu = null;
if (!revoltzState.originalAddEventListener) {
revoltzState.originalAddEventListener = EventTarget.prototype.addEventListener;
}
if (!revoltzState.rightclickPatched) {
const blocked = ["contextmenu", "selectstart", "dragstart", "mousedown"];
const origAdd = revoltzState.originalAddEventListener;
EventTarget.prototype.addEventListener = function (type, fn, opts) {
if (blocked.includes(type)) return;
return origAdd.call(this, type, fn, opts);
};
revoltzState.rightclickPatched = true;
}
}
if (mode === "all" || mode === "console") {
if (!revoltzState.originalSetInterval) {
revoltzState.originalSetInterval = window.setInterval;
}
if (!revoltzState.consolePatched) {
const origSetInterval = revoltzState.originalSetInterval;
window.setInterval = function (fn, ms, ...args) {
const fnStr = typeof fn === "function" ? fn.toString() : String(fn);
if (fnStr.includes("debugger") || fnStr.includes("console")) return 0;
return origSetInterval.call(this, fn, ms, ...args);
};
const handler = {
get(target, prop) {
return target[prop];
},
};
try { window.console = new Proxy(console, handler); } catch (e) {}
revoltzState.consolePatched = true;
}
}
if (mode === "all" || mode === "select") {
document.onselectstart = null;
document.ondragstart = null;
}
if (mode === "all" || mode === "copy") {
document.oncopy = null;
document.oncut = null;
document.onpaste = null;
}
})();