// ==UserScript== // @name 去除切换标签页事件 // @namespace https://github.com/GXhunter/ // @version 1.2 // @description Removes all visibilitychange, pagehide, and beforeunload events from the page // @match *://*/* // @license MIT // @grant unsafeWindow // @run-at document-start // @downloadURL none // ==/UserScript== (function () { const stopEventPropagation = (event) => { event.stopImmediatePropagation() event.stopPropagation(); event.preventDefault(); }; 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 })();