您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Display option to translate the current page with google translate in violentmonkey menu
- // ==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)
- })();