禁用浏览器快捷键窗口

chrome、edge等浏览器中会弹出窗口,经常会误触,故禁用所有页面中的快捷键

目前為 2024-05-28 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         禁用浏览器快捷键窗口
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  chrome、edge等浏览器中会弹出窗口,经常会误触,故禁用所有页面中的快捷键
// @author       forcier
// @match        *://*/*
// @match        *://kimi.moonshot.cn/*
// @license      MIT
// @run-at document-start
// @grant        none
// @grant       unsafeWindow
// @supportURL   https://bbs.tampermonkey.net.cn/forum.php?mod=viewthread&tid=270
// @homepage     https://bbs.tampermonkey.net.cn/forum.php?mod=viewthread&tid=270
// ==/UserScript==
(function () {
	"use strict";
	var style = document.createElement('style');
	style.type = 'text/css';
  setTimeout(()=>{
    document.body.style.fontFamily = '萍方-简 !important';
    style.innerHTML = `* {font-family: 萍方-简 !important;}  span {font-family: 萍方-简 !important;}`;
  },100)
	document.head.appendChild(style);

	function debounce(func, delay) {
		let timeout;
		return function (...args) {
			clearTimeout(timeout);
			timeout = setTimeout(() => func.apply(this, args), delay);
		};
	}

	const handleMouseDown = debounce((event) => {
		if ('which' in event) {
			switch (event.which) {
				case 1:
					break;
				case 2:
					break;
				case 3:
					break;
				default:
					if (window.history.length === 1) window.close();
					break;
			}
		}
	}, 200);

	document.addEventListener('mousedown', handleMouseDown);


	document.addEventListener("keydown", function (e) {
		"F1" == e.key && e.preventDefault();
	});

	document.addEventListener("keydown", function (e) {
		"F3" == e.key && e.preventDefault();
	});

	document.addEventListener("keydown", function (e) {
		"F7" == e.key && e.preventDefault();
	});

	document.addEventListener("keydown", function (e) {
		"F9" == e.key && e.preventDefault();
	});


})();