谷歌翻译 粘贴 去除换行

谷歌翻译 粘贴 去除 换行 Google translate paste remove delete line break new line

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.

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

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

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

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

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

// ==UserScript==
// @name         谷歌翻译 粘贴 去除换行
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description   谷歌翻译 粘贴 去除 换行 Google translate paste remove delete line break new line
// @author        批小将
// @match         https://translate.google.com/*
// @grant         none
// ==/UserScript==

(function() {
    'use strict';
    let txarea = document.getElementById('source');
    txarea.addEventListener('input', function(){
    //得到的是已经改变过后的内容,跟'paste' event不一样
    let text = txarea.value;
    let replace_text = text.replace(/\n/g, ' ');
    txarea.value = replace_text;
    });
})();