Redirect to Google Translator

Instead of using the small translator on https://google.com get redirected to https://translate.google.com

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

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Redirect to Google Translator
// @namespace    GoogleTranslatorRedirector
// @version      7
// @description  Instead of using the small translator on https://google.com get redirected to https://translate.google.com
// @author       hacker09
// @include      *://www.google.*
// @icon         https://t2.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=https://translate.google.com/&size=32
// @run-at       document-end
// @grant        none
// @noframes
// ==/UserScript==

(function() {
  'use strict';
  if (document.querySelector("#tw-main") !== null) // If the small translator widget exists on the page
  { //Starts the if conditon
    var Redirect = setTimeout(function() { //Starts the settimeout function
      window.open('https://translate.google.com', '_self'); //Redirect to google translate
    }, 3000); //Redirect to https://translate.google.com in 3 secs

    document.body.insertAdjacentHTML('beforeend', '<div id="Redirect" style="width: 100vw; height: 100vh; z-index: 2147483647; background: rgb(0 0 0 / 36%); position: fixed; top: 0px; font-size: 50px; color: white;"><center>You\'ve 3 secs to click Anywhere if you don\'t want to be redirected</center></div>'); //Show an option to the user

    document.querySelector("#Redirect").onclick = function() { //If anywhere is clicked
      clearTimeout(Redirect); //Stop the redirecting process
      document.querySelector("#Redirect").style.display = 'none'; //Hide the option
    } //Stop the redirection if the user clicks anywhere
  } //Finishes the if conditon
})();