您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adds a feature that adds a shortcut key that auto-clicks the Google Translate extension icon on Chrome browsers for the quick and better language learning experience.
// ==UserScript== // @name Google Translate Icon Auto Click // @namespace http://tampermonkey.net/ // @version 0.1 // @description Adds a feature that adds a shortcut key that auto-clicks the Google Translate extension icon on Chrome browsers for the quick and better language learning experience. // @author You // @match http://*/* // @match https://*/* // @require https://cdn.jsdelivr.net/npm/[email protected]/build/alertify.min.js // @resource alertify.min.css https://cdn.jsdelivr.net/npm/[email protected]/build/css/alertify.min.css // @resource default.min.css https://cdn.jsdelivr.net/npm/[email protected]/build/css/themes/default.min.css // @grant GM_addStyle // @grant GM_getResourceText // @require https://unpkg.com/[email protected]/dist/url-parse.js // @require https://cdn.jsdelivr.net/npm/[email protected]/lodash.min.js // @require https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js // @run-at document-idle // @noframes // @license mit // ==/UserScript== function waitForElm(selector) { // wait for element return new Promise(resolve => { if (document.querySelector(selector)) { return resolve(document.querySelector(selector)); } const observer = new MutationObserver(mutations => { if (document.querySelector(selector)) { resolve(document.querySelector(selector)); observer.disconnect(); } }); observer.observe(document.body, { childList: true, subtree: true }); }); } function getSelectionText() { var text = ""; if(window.location.hostname == "docs.google.com") { var googleDocument = googleDocsUtil.getGoogleDocument(); text = googleDocument.selectedText; } else { if (window.getSelection) { text = window.getSelection().toString(); } else if (document.selection && document.selection.type != "Control") { text = document.selection.createRange().text; } } return text.trim(); } // alt + double click to auto click google translate icon document.addEventListener('dblclick', async function(e){ var searchWord = getSelectionText() if(searchWord != "") { if (e.altKey) { await waitForElm('#gtx-trans'); document.querySelector('#gtx-trans').click() } } })
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址