如何全局和永久禁用chromes打开功能
"离开现场?"更改可能无法保存"弹出窗口。
我想关闭每个 chrome 窗口的每个选项卡,我知道我在做什么,当我试图关闭时,我不需要保姆应用程序来防止我的关机或妨碍我。
我尝试使用篡改猴子脚本来禁用"onbeforeunload"事件,但它们并没有阻止这种令人讨厌的行为。
- 通过在元数据块中声明
@run-at document-start
,在页面执行之前安装beforeunload
侦听器。 - 调用
stopImmediatePropagation
以防止随后添加的页面侦听器看到事件。 - 也清楚
window.onbeforeunload
.
// ==UserScript==
// @name ignore beforeunload
// @match *://*/*
// @grant none
// @run-at document-start
// ==/UserScript==
window.addEventListener('beforeunload', e => {
window.onbeforeunload = null;
e.stopImmediatePropagation();
});