Google Translate Page

Display option to translate the current page with google translate in violentmonkey menu

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

You will need to install an extension such as Tampermonkey to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name        Google Translate Page
// @namespace   432346-fke9fgjew89gjwe89
// @match       *://*/*
// @grant       GM_registerMenuCommand
// @noframes
// @version     1.2
// @icon        https://translate.google.com/favicon.ico
// @author      432346-fke9fgjew89gjwe89
// @description Display option to translate the current page with google translate in violentmonkey menu
// ==/UserScript==

(function () {
  'use strict';

  if (window.top != window.self)
    return;
  var d = document;

  function translate() {
    
    document.cookie = "googtrans=/auto/en; path=/";

    var d, b, o, v, p;
    b = (d = document).body;
    o = d.createElement('script');
    o.setAttribute('src', 'https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit');
    o.setAttribute('type', 'text/javascript');
    b.appendChild(o);
    v = b.insertBefore(d.createElement('div'), b.firstChild);
    v.id = 'google_translate_element';
    v.style.display = 'none';
    p = d.createElement('script');
    p.text = 'function googleTranslateElementInit(){new google.translate.TranslateElement({pageLanguage:"auto"},"google_translate_element");}';
    p.setAttribute('type', 'text/javascript');
    b.appendChild(p);
  }

  GM_registerMenuCommand("Translate this page", translate)

})();