Translator

Press (F2) to Translate.

当前为 2024-05-01 提交的版本,查看 最新版本

// ==UserScript==
// @name Translator
// @name:de Übersetzer
// @description Press (F2) to Translate.
// @description:de Drücken Sie (F2) zum übersetzen.
// @version 4.0.4.3
// @icon https://translate.google.com/favicon.ico
// @author JAS1998
// @copyright 2023+ , JAS1998
// @namespace https://greasyfork.org/users/4792
// @license CC BY-NC-ND 4.0; http://creativecommons.org/licenses/by-nc-nd/4.0/
// @compatible Chrome tested with Tampermonkey
// @contributionURL https://www.paypal.com/donate?hosted_button_id=9JEGCDFJJHWU8
// @run-at document-end
// @match *://*/*
// @exclude /^[a-z]{4}.*\/greasyfork\.org\/.*\/4610.*$
// @grant GM_notification
// ==/UserScript==

/* jshint esversion: 9 */

document.onkeydown = function(event) {
    checkForF2Press(event);
};

function checkForF2Press(event) {
    event = window.event ? event : event;
    if (event.keyCode == 113) {
        if (GM_info.script.copyright.includes(GM_info.script.namespace)) {
            location.href = "http://translate.google.com/translate?sl=auto&u=" + window.location;
            GM_notification({
                title: GM_info.script.name,
                text: "Post a review, comment, or question",
                timeout: "10000",
                onclick: function () {
                    location.href = GM_info.script.supportURL;
                },
            });
        } else {
            location.href = GM_info.script.supportURL.replace("feedback", "");
            alert("Please install the Orginal Version");
        }
    }
}

if (window.location.host.includes('translate.google')) {
    console.log("Post a review, comment, or question\n" + GM_info.script.supportURL + "\n\nCopyright " + GM_info.script.copyright);
}