Translate Helper

翻译去换行

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==UserScript==
// @name         Translate Helper
// @namespace    http://tampermonkey.net/
// @version      3.2
// @description  翻译去换行
// @author       o1hy
// @match        https://translate.google.com/*
// @match        https://translate.google.cn/*
// @match        https://www.deepl.com/*
// @match        https://fanyi.sogou.com/*
// @match        http://fanyi.youdao.com/*
// @grant        none
// ==/UserScript==

function new_version(){
    var url = window.location.href

    if(url.includes("deepl.com")){
        var a = document.querySelector("#dl_translator > div > div > div > div > div > textarea");
    }else if(url.includes("translate.google")){
        var a = document.querySelector("body > c-wiz > div > div > c-wiz > div > c-wiz > div > div > div > c-wiz > span > span > div > textarea");
    }else if(url.includes("sogou.com")){
        var a = document.querySelector("#trans-input");
    }else if(url.includes("fanyi.youdao.com")){
        var a = document.querySelector("#inputOriginal");
    }

    a.addEventListener("paste",function(event){

        let paste = (event.clipboardData || window.clipboardData).getData('text');

        paste = paste.replaceAll("\n"," ")
        paste = paste.replaceAll("\r"," ")

        document.execCommand("insertText",false,paste)
        event.preventDefault();
    })
}



(function() {
   'use strict';
   new_version();
})();