切屏也能保持网页标题不变,让你轻松找到想要的网页!
// ==UserScript==
// @name 阻止切屏检测
// @namespace http://tampermonkey.net/
// @version 0.2
// @description 切屏也能保持网页标题不变,让你轻松找到想要的网页!
// @author GR:PM
// @license MIT
// @match *://*/*
// @grant none
// ==/UserScript==
;(function () {
"use strict"
Object.defineProperty(window, "onblur", {
value: null,
writable: false,
})
Object.defineProperty(document, "onblur", {
value: null,
writable: false,
})
Object.defineProperty(window, "onmouseleave", {
value: null,
writable: false,
})
Object.defineProperty(document, "onmouseleave", {
value: null,
writable: false,
})
Object.defineProperty(window, "onvisibilitychange", {
value: null,
writable: false,
})
Object.defineProperty(document, "onvisibilitychange", {
value: null,
writable: false,
})
// Backup original addEventListener
const originalEventTargetAddEventListener = EventTarget.prototype.addEventListener
const originalHTMLElementAddEventListener = HTMLElement.prototype.addEventListener
const originalWindowAddEventListener = Window.prototype.addEventListener
const originalDocumentAddEventListener = Document.prototype.addEventListener
function isBlocked(eventName) {
if (
eventName === "visibilitychange" ||
eventName === "focus" ||
eventName === "focusin" ||
eventName === "focusout" ||
eventName === "blur" ||
eventName === "mouseleave"
) {
return true
} else {
return false
}
}
EventTarget.prototype.addEventListener = function (eventName, eventHandler) {
if (isBlocked(eventName)) {
console.log(`Blocked listener: ${eventName}`)
} else {
// console.log(`Bypass listener: ${eventName}`);
originalEventTargetAddEventListener.call(this, eventName, eventHandler)
}
}
HTMLElement.prototype.addEventListener = function (eventName, eventHandler) {
if (isBlocked(eventName)) {
console.log(`Blocked listener: ${eventName}`)
} else {
// console.log(`Bypass listener: ${eventName}`);
originalHTMLElementAddEventListener.call(this, eventName, eventHandler)
}
}
Window.prototype.addEventListener = function (eventName, eventHandler) {
if (isBlocked(eventName)) {
console.log(`Blocked listener: ${eventName}`)
} else {
// console.log(`Bypass listener: ${eventName}`);
originalWindowAddEventListener.call(this, eventName, eventHandler)
}
}
Document.prototype.addEventListener = function (eventName, eventHandler) {
if (isBlocked(eventName)) {
console.log(`Blocked listener: ${eventName}`)
} else {
// console.log(`Bypass listener: ${eventName}`);
originalDocumentAddEventListener.call(this, eventName, eventHandler)
}
}
})()