全局禁用 Nag 模态 "Leave Site" "Changes may not be saved" 铬



如何全局和永久禁用chromes打开功能

"离开现场?"更改可能无法保存"弹出窗口。

我想关闭每个 chrome 窗口的每个选项卡,我知道我在做什么,当我试图关闭时,我不需要保姆应用程序来防止我的关机或妨碍我。

我尝试使用篡改猴子脚本来禁用"onbeforeunload"事件,但它们并没有阻止这种令人讨厌的行为。

  1. 通过在元数据块中声明@run-at document-start,在页面执行之前安装beforeunload侦听器。
  2. 调用stopImmediatePropagation以防止随后添加的页面侦听器看到事件。
  3. 也清楚window.onbeforeunload.
// ==UserScript==
// @name        ignore beforeunload 
// @match       *://*/*
// @grant       none
// @run-at      document-start
// ==/UserScript==
window.addEventListener('beforeunload', e => {
window.onbeforeunload = null;
e.stopImmediatePropagation();
});

相关内容

最新更新