Google Search Translate Button

Adds a Translate button to the Google Search page

< Feedback em Google Search Translate Button

Avaliação: Bom - o script funciona

§
Publicado: 17/12/2017
Editado: 17/12/2017

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 += `

`;
})();

gllmsAutor
§
Publicado: 27/02/2018

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.

Publicar resposta

Faça o login para publicar uma resposta.