您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Fix shift+option+number keys in Google Sheets on Mac while using a Scandinavian keyboard layout, by interception of shift+option+number keys, and replace them with the correct char pasted in. Flaws: Does not enter edit mode when inserting into inactivated sheet cells.
当前为
// ==UserScript== // @name Google Sheets Enable Scandinavian Keyboard On Mac // @namespace https://gist.github.com/f-steff // @version 1.1 // @description Fix shift+option+number keys in Google Sheets on Mac while using a Scandinavian keyboard layout, by interception of shift+option+number keys, and replace them with the correct char pasted in. Flaws: Does not enter edit mode when inserting into inactivated sheet cells. // @author Flemming Steffensen // @match https://docs.google.com/spreadsheets/* // @grant none // @homepageURL https://gist.github.com/f-steff/ace84434e1ee4e1107bcf0ba8d72ed2b // @run-at document-start // ==/UserScript== function simulatePaste(code, character) { navigator.clipboard.writeText(character).then(() => { document.execCommand('paste'); }); } (function() { 'use strict'; var isMac = navigator.platform.indexOf("Mac") === 0 if (!isMac) return; // Only a fix for Mac computer // Store the original addEventListener function const originalAddEventListener = EventTarget.prototype.addEventListener; // To my supprise, browser keyboard events are unfiltered hardware events, so they need debounching. const debounceTime = 50; // milliseconds let lastInvocationTime = 0; // Hack: Override addEventListener on the EventTarget prototype EventTarget.prototype.addEventListener = function(type, listener, options) { const isPassive = options && (typeof options === 'object') && options.passive; const customListener = (event) => { if (type === "keydown" && event.shiftKey && event.altKey && event.code.startsWith("Digit")) { if (!isPassive) { event.preventDefault(); // Prevent the default key action } const currentTime = new Date().getTime(); if (currentTime - lastInvocationTime > debounceTime) { console.log("Current: " + currentTime + " Last: " + lastInvocationTime + " = Shift and Option are pressed together with " + event.code); lastInvocationTime = currentTime; // Handle keys if (event.code === "Digit1") { simulatePaste(event.code, "¯"); } // Sheets mapping is: upper border set else if (event.code === "Digit2") { simulatePaste(event.code, "”"); } // Sheets mapping is: right border set else if (event.code === "Digit3") { simulatePaste(event.code, "$"); } // Sheets mapping is: lower border set else if (event.code === "Digit4") { simulatePaste(event.code, "¢"); } // Sheets mapping is: left border set else if (event.code === "Digit5") { simulatePaste(event.code, "‰"); } else if (event.code === "Digit6") { simulatePaste(event.code, "˜"); } // Sheets mapping is: all border clear else if (event.code === "Digit7") { simulatePaste(event.code, "\\"); } // Sheets mapping is: all border set else if (event.code === "Digit8") { simulatePaste(event.code, "{"); } else if (event.code === "Digit9") { simulatePaste(event.code, "}"); } else if (event.code === "Digit0") { simulatePaste(event.code, "≈"); } } else return; } else { listener.call(this, event); } }; // Call the original addEventListener function originalAddEventListener.call(this, type, customListener, options); }; })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址