您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
任意网页选中自动朗读
当前为
// ==UserScript== // @name 选中自动朗读 // @namespace http://tampermonkey.net/ // @version 0.2 // @description 任意网页选中自动朗读 // @license 选中自动朗读 // @author lgldlk // @match *://*/* // @icon https://www.google.com/s2/favicons?sz=64&domain=chrome.com // @grant none // ==/UserScript== // 定义一个防抖函数 function debounce(fn, delay) { let timeout; return function () { clearTimeout(timeout); timeout = setTimeout(() => { fn.apply(this, arguments); }, delay); }; } (function () { 'use strict'; const speakFunc = debounce(function () { let text = String(document.getSelection()); if (!text.length || text.length > 200) return; speechSynthesis.cancel(); speechSynthesis.speak(new SpeechSynthesisUtterance(text)); }, 300); document.addEventListener('selectionchange', speakFunc); })();