您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
https://github.com/srghma-chinese2/srghma-chinese2.github.io
// ==UserScript== // @name Google Lens autoopen translation // @namespace http://tampermonkey.net/ // @version 0.1 // @description https://github.com/srghma-chinese2/srghma-chinese2.github.io // @author [email protected] // @match https://lens.google.com/search* // @license MIT // @icon https://www.google.com/s2/favicons?sz=64&domain=google.com // @grant none // ==/UserScript== function doAsynclyOnce({ id, isValid, onValid, onInvalid }) { let retries = 300; const intervalID = setInterval(_ => { const element = document.getElementById(id); const valid = isValid(element); console.log('trying ', id, ', element=', element, ', valid=', valid) if (valid) onValid(element) else onInvalid && onInvalid() retries--; if(retries === 0 || valid) clearInterval(intervalID); }, 100); } (function() { 'use strict'; console.log('asdfasdf') doAsynclyOnce({ id: "translate", isValid: spanWithButton => !!spanWithButton, onValid: spanWithButton => { console.log(spanWithButton) spanWithButton.querySelector('button').click() doAsynclyOnce({ id: "ucc-4", isValid: element => !!element, onInvalid: () => { spanWithButton.querySelector('button').click() }, onValid: element => { element.click() setTimeout(() => window.close(), 900) } }) } }) })();