chrome、edge等浏览器中会弹出窗口,经常会误触,故禁用所有页面中的快捷键
目前為
// ==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();
});
})();