您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Prevents accidental Ctrl+W from closing current tab while you are typing something (input/textarea tag is active). You can change the whit list of websites (on which this script will be "enabled").
// ==UserScript== // @name Ctrl+Won't // @namespace http://tampermonkey.net/ // @version 2024-03-17 // @description Prevents accidental Ctrl+W from closing current tab while you are typing something (input/textarea tag is active). You can change the whit list of websites (on which this script will be "enabled"). // @author Andrew15-5 // @match *://*/* // @icon https://i.ytimg.com/vi/Qa5xfIbMaqw/maxresdefault.jpg // @grant none // @license AGPL-3.0 // ==/UserScript== (function () { 'use strict'; const whitelist = [ 'github.com', 'discord.com', 'stackoverflow.com', 'greasyfork.org', ]; if (!whitelist.includes(location.hostname)) { return; } addEventListener( 'beforeunload', function (e) { if (location.hostname === 'discord.com') { if ( document.activeElement.localName !== 'div' || document.activeElement.getAttribute('role') !== 'textbox' ) { return; } } else if ( !['input', 'textarea'].includes(document.activeElement.localName) ) { return; } e.stopPropagation(); e.preventDefault(); return false; }, true, ); })();