Adds a Translate button to the Google Search page
< 腳本Google Search Translate Button的回應
Thanks for the idea, but JavaScript already has a built-in function for escaping all sorts of characters: encodeURI(). So I'm going to use that in the new update.
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址
Fix Quotes issue
I updated the script to fix an issue when searching a text containing quotes...
// ==UserScript==
Translate `;
// @name Google Search Translate Button
// @namespace http://tampermonkey.net/
// @version 0.3
// @description Adds a Translate button to the Google Search page
// @author gllms
// @include *://www.google.tld/search*
// @grant none
// @licence https://opensource.org/licenses/mit-license.php
// ==/UserScript==
(function() {
'use strict';
var search = document.getElementById("lst-ib").value;
var search_unescaped = search.replace(new RegExp('"', 'g'),'"');
var url = "https://translate.google.com/#auto/en/" + search_unescaped;
document.getElementById("hdtb-msb-vis").innerHTML += `
})();