您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Script that reads selected text on artofchording.com (change @match to make it work for other sites).
当前为
// ==UserScript== // @name Text-to-speech for artofchording.com // @match https://www.artofchording.com/* // @grant none // @version 1.0 // @author Rebane // @description Script that reads selected text on artofchording.com (change @match to make it work for other sites). // @namespace https://greasyfork.org/users/447264 // ==/UserScript== /* jshint esversion: 6 */ // Initiate speechSynthesis var synth = window.speechSynthesis; var voices = []; // Load and log voices when ready if (speechSynthesis.onvoiceschanged !== undefined) { speechSynthesis.onvoiceschanged = () => { voices = synth.getVoices(); console.log(voices); }; } // Choose your voice id here if you wish to change it var selectedVoice = 0; // When more than one character is selected on mouseup, speak the selection window.addEventListener('mouseup', function(event){ if (window.getSelection) { // all browsers, except IE before version 9 let text = window.getSelection().toString(); if (text.length > 1){ // Uncomment to log selected text //console.log(text); let utterThis = new SpeechSynthesisUtterance(text); utterThis.voice = voices[selectedVoice]; synth.speak(utterThis); } } })