Priest-zhi / Tampermonkey_js

0 stars 0 forks source link

Chrome translation 自动排版 #1

Open Priest-zhi opened 6 years ago

Priest-zhi commented 6 years ago

// ==UserScript== // @name Google translation replace character // @namespace https://translate.google.cn/ // @version 0.1 // @description press F5 // @author quz // @include https://translate.google./ // @match https://*translate.google./ // @grant none // ==/UserScript==

(function() { 'use strict'; //you can change what you want var txt = "";
txt = document.getElementById("source").value; //去除空格 if(txt.indexOf("\n")) { txt = txt.replace(/\n/g," "); }

//按句子分段
if(txt.indexOf("."))
{
    txt = txt.replace(/\. /g,".\n\n");
}
document.getElementById("source").value = txt; 

})();

Priest-zhi commented 6 years ago

How to install https://greasyfork.org/zh-CN/scripts/370416-google-translation-formatting