// ==UserScript== // @name 谷歌翻译辅助 // @version 0.1 // @description 为谷歌翻译输入框中的内容自动删除换行! // @author hustcc // @include *://translate.google.com/* // @match *://translate.google.com/* // @connect translate.google.com // @grant unsafeWindow // @namespace https://atool.vip/ // @downloadURL none // ==/UserScript== (function() { 'use strict'; if (window.location.host !== 'translate.google.com') return; let timer = 0; function loop() { const ele = document.getElementById('source'); if (ele) { const t = ele.value; if (t) { const r = t.replace(/\n/g, ' '); if (r !== t) { ele.value = r; } } } // timer clearTimeout(timer); timer = setTimeout(() => { loop(); }, 1000); } timer = setTimeout(() => { loop(); }, 1000); })();