谷歌翻译 粘贴 去除换行

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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;
    });
})();