Last active
December 28, 2024 19:06
-
-
Save kenvix/0daec29504972b502790109a1f155902 to your computer and use it in GitHub Desktop.
iTest 爬
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name fuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuck | |
// @namespace https://kenvix.com/ | |
// @version 0.1 | |
// @description try to fuck over the world! | |
// @author Kenvix | |
// @match *://*/* | |
// @grant none | |
// ==/UserScript== | |
// document.addEventListener('visibilitychange', () => { console.warn("!!!") }); window.addEventListener("focus", () => { console.warn("!!!") }); | |
var blockedEventTypesSet = new Set(["visibilitychange", "focus", "blur", "online", "offline", "paste", "contextmenu", "beforecopy", "error", "selectstart", "copy", "cut", "select", "dragstart", "beforeunload", "mousedown", "mouseup", "mousemove"]); | |
var windowListeners = {}; | |
var originalWindowEventListener = window.addEventListener; | |
window.addEventListener = function(type, fn, options) { | |
if (blockedEventTypesSet.has(type)) | |
return; | |
if (!windowListeners[type]) | |
windowListeners[type] = []; | |
windowListeners[type].push(fn); | |
return originalWindowEventListener(type, fn, options); | |
} | |
window.removeAllEventListener = function(type) { | |
if (!windowListeners[type] || !windowListeners[type].length) | |
return; | |
for (let i = 0; i < windowListeners[type].length; i++) | |
window.removeEventListener(type, windowListeners[type][i]); | |
} | |
var documentListeners = {}; | |
var originalDocumentEventListener = document.addEventListener; | |
document.addEventListener = function(type, fn, options) { | |
if (blockedEventTypesSet.has(type)) | |
return; | |
if (!documentListeners[type]) | |
documentListeners[type] = []; | |
documentListeners[type].push(fn); | |
return originalDocumentEventListener(type, fn, options); | |
} | |
document.removeAllEventListener = function(type) { | |
if (!documentListeners[type] || !documentListeners[type].length) | |
return; | |
for (let i = 0; i < documentListeners[type].length; i++) | |
document.removeEventListener(type, documentListeners[type][i]); | |
} | |
function disableEventListenerFunction(event) { | |
event.stopPropagation(); | |
console.log("Intercepted event " + event) | |
} | |
function disableAllEventListeners(target, name) { | |
getEventListeners(target)[name].forEach((e) => { | |
target.removeEventListener(name, e.listener); | |
}); | |
} | |
function withErrorIgnored(fun) { | |
try { | |
fun(); | |
} catch (e) { console.warn(e) } | |
} | |
function getElementsN() { | |
var elements = Array.prototype.slice.call(document.getElementsByTagName('*')); | |
elements.push(document); | |
var frames = document.querySelectorAll("frame"); | |
if(frames) { | |
var hasFrame = frames; | |
var frames_element; | |
for (let i = 0;i<frames.length;i++){ | |
frames_element = Array.prototype.slice.call(frames[i].contentWindow.document.querySelectorAll("*")); | |
elements.push(frames[i].contentWindow.document); | |
elements = elements.concat(frames_element); | |
} | |
} | |
return elements; | |
} | |
function clearLimitationEvents() { | |
window.onblur = null; | |
window.onfocus = null; | |
window.oninput = null; | |
window.onpaste = null; | |
window.onbeforecopy = null; | |
window.onoffline = null; | |
window.ononline = null; | |
window.onerror = null; | |
getElementsN().forEach(element => { | |
element.onpaste = null; | |
element.onfocus = null; | |
element.onblur = null; | |
element.oninput = null; | |
element.onbeforecopy = null; | |
element.oncontextmenu = null; | |
element.ondragstart = null; | |
element.oncopy = null; | |
element.oncut = null; | |
element.onbeforecopy = null; | |
element.onselectstart = null; | |
if (typeof(element.spellcheck) != "undefined" && element.spellcheck != null && !element.spellcheck) { | |
element.spellcheck = true; | |
} | |
if (typeof(element.autocomplete) != "undefined" && element.autocomplete != null && !element.autocomplete) { | |
element.autocomplete = true; | |
} | |
}); | |
withErrorIgnored(() => { window.removeAllEventListener("focus") }); | |
withErrorIgnored(() => { window.removeAllEventListener("blur") }); | |
withErrorIgnored(() => { window.removeAllEventListener("input") }); | |
withErrorIgnored(() => { window.removeAllEventListener("paste") }); | |
withErrorIgnored(() => { window.removeAllEventListener("offline") }); | |
withErrorIgnored(() => { window.removeAllEventListener("online") }); | |
withErrorIgnored(() => { window.removeAllEventListener("visibilitychange") }); | |
withErrorIgnored(() => { document.removeAllEventListener("visibilitychange") }); | |
console.info("<<< Limitation Events clear >>>"); | |
} | |
clearLimitationEvents(); | |
setInterval(clearLimitationEvents, 4000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment