Greasy Fork

Greasy Fork is available in English.

pdf复制去回车脚本

复制PDF的内容之后,点击Change按钮,实现去回车翻译

当前为 2019-07-30 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         pdf复制去回车脚本
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  复制PDF的内容之后,点击Change按钮,实现去回车翻译
// @author       sun_liber
// @match        https://fanyi.baidu.com/*
// @match        http://fanyi.youdao.com/*
// @match        https://translate.google.cn/*
// @match        https://translate.google.com/*
// @match        https://translate.google.com/*
// ==/UserScript==

(function() {
    var txt = "";
    var id = "";
    var transButtonId=""
    var host = window.location.host;
    if( host == "fanyi.baidu.com" )
    {
       id = "baidu_translate_input";
        transButtonId="translate-button";
    }
    if( host == "fanyi.youdao.com" )
    {
       id = "inputOriginal";
        transButtonId="transMachine";
    }
    if( host == "translate.google.cn" || host == "translate.google.com" )
    {
       id = "source";
       //谷歌翻译好像没有按钮
    }


    var button = document.createElement('button');
    button.setAttribute('style','position:fixed;top:300px;left:30px;');
    button.textContent="Change";
    button.onclick=function(){
          txt = document.getElementById(id).value;
        for (var i=0;i<txt.length;i++)
        {
            if(txt.indexOf("\n"))txt = txt.replace("\n"," ");
        }
        document.getElementById(id).value = txt;

        transButtonId!==""?document.getElementById(transButtonId).click():console.log("谷歌大法好啊");

    }
    document.body.appendChild(button);
})();