Last active
March 17, 2022 08:17
-
-
Save rockonyu/b0ac44989a4aa8603733904397f0f568 to your computer and use it in GitHub Desktop.
將程式碼加入書籤,可以唸出當前滑鼠選擇的文字。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript: (() => { | |
const synth = window.speechSynthesis; | |
if (synth.speaking) { | |
synth.cancel(); | |
return; | |
} | |
const selectedText = window.getSelection().toString(); | |
if (!selectedText) { | |
return; | |
} | |
synth.speak(new SpeechSynthesisUtterance(selectedText)) | |
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(()=>{const e=window.speechSynthesis;if(e.speaking)return void e.cancel();const n=window.getSelection().toString();n&&e.speak(new SpeechSynthesisUtterance(n))})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
額外參考: