Adds a Translate button to the Google Search page
< Commentaires sur 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.
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 += `
})();