您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Wrap the selected word in HTML to "highlight" it in the sentence.
// ==UserScript== // @name Kitsun Highlight Word in Sentence // @namespace https://kitsun.io // @description Wrap the selected word in HTML to "highlight" it in the sentence. // @author seanblue // @version 1.0.1 // @include https://kitsun.io/* // @grant none // ==/UserScript== (function() { 'use strict'; const requiredKey = 115; // F4 const openTag = '<span class="highlight">'; const closeTag = '</span>'; document.addEventListener('keydown', onKeyDown); function onKeyDown(e) { if (e.keyCode === requiredKey) { wrapSelectedTextInHighlightSpan(); } } function wrapSelectedTextInHighlightSpan() { let el = document.activeElement; let start = el.selectionStart; let end = el.selectionEnd; if (start === end) { return; } let beforeText = el.value.substring(0, start); let selectedText = el.value.substring(start, end); let afterText = el.value.substring(end, el.value.length); let modifiedText = beforeText + openTag + selectedText + closeTag + afterText; el.value = modifiedText; el.selectionStart = end + openTag.length + closeTag.length; el.selectionEnd = el.selectionStart; el.dispatchEvent(new Event('change')); } })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址