您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Removes all visibilitychange, pagehide, and beforeunload events from the page
当前为
// ==UserScript== // @name 去除切换标签页事件 // @namespace https://github.com/GXhunter/ // @version 1.1 // @description Removes all visibilitychange, pagehide, and beforeunload events from the page // @match *://*/* // @license MIT // @grant unsafeWindow // @run-at document-idle // ==/UserScript== (function () { setTimeout(() => { const stopEventPropagation = (event) => { event.stopImmediatePropagation() event.stopPropagation(); event.preventDefault(); }; console.log(window.getEventListeners(window)) unsafeWindow.addEventListener('visibilitychange', stopEventPropagation, true); unsafeWindow.addEventListener('pagehide', stopEventPropagation, true); unsafeWindow.addEventListener('beforeunload', stopEventPropagation, true); unsafeWindow.addEventListener('blur', stopEventPropagation, true); unsafeWindow.addEventListener('focus', stopEventPropagation, true); unsafeWindow.onfocus = null unsafeWindow.onblur = null unsafeWindow.onpagehide = null unsafeWindow.onbeforeunload = null }, 1000) })();