Google Search Translate Button

Adds a Translate button to the Google Search page

< 腳本Google Search Translate Button的回應

評論:正評 - 腳本一切正常

§
發表於:2017-12-17
編輯:2017-12-17

Fix Quotes issue

I updated the script to fix an issue when searching a text containing quotes...

// ==UserScript==
// @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 += `

`;
})();

gllms作者
§
發表於:2018-02-27

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或关注我们的公众号极客氢云获取最新地址