您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
下载 Google 翻译的英语发音
// ==UserScript== // @name Google Translate Audio Download // @namespace Quoyi // @version 0.1 // @description 下载 Google 翻译的英语发音 // @author iQuoyi // @match https://guides.rubyonrails.org/* // @require https://code.jquery.com/jquery-3.6.0.min.js // @grant unsafeWindow // @grant GM_download // @license MIT // ==/UserScript== (function() { 'use strict'; const $ = window.jQuery; $(function() { document.addEventListener('mouseup', event => { // 获取选中文本 const text = window.getSelection().toString(); if (text.length) { // 获取发音文件并保存 $('<button/>', { id: 'download-button', text: '下载', style: `position: absolute; left: ${event.layerX}px; top: ${event.layerY - 20}px; z-index: 1024;`, click: (e) => GM_download({ url: `https://translate.google.com/translate_tts?client=tw-ob&tl=en&q=${text}`, name: `${text}.mp3`, saveAs: false }), }).appendTo('body'); } else { // 清除已有按钮 $('#download-button').remove(); } }); }); })();