翻译去换行
当前为
// ==UserScript==
// @name Translate Helper
// @namespace http://tampermonkey.net/
// @version 1.0
// @description 翻译去换行
// @author o1hy
// @match https://translate.google.com
// @match https://translate.google.cn
// @grant none
// ==/UserScript==
function injectText(){
var temp = document.createElement('input');
temp.type = 'text';
// temp.value = '';
temp.id = 'source_text';
temp.className = 'tlid-source-target main-header'
temp.style = "border-bottom-width:0;height: 20px;padding-top: 0px;width: 50%; margin-top: 8px;"
document.getElementsByClassName('tlid-result-view cllist')[0].append(temp);
// document.body.append(temp);
temp = document.createElement('button');
temp.textContent = 'Translate';
temp.id = 'my-trans'
temp.className="tlid-input-button input-button header-button tlid-input-button-text"
temp.style="padding-left: 16px; height: 24px;left: 10px;"
document.getElementsByClassName('tlid-result-view cllist')[0].append(temp);
// document.body.append(temp);
temp = document.createElement('button');
temp.textContent = 'Clear';
temp.id = 'clear'
temp.className="tlid-input-button input-button header-button tlid-input-button-text"
temp.style="padding-left: 16px; height: 24px;left: 10px;"
document.getElementsByClassName('tlid-result-view cllist')[0].append(temp);
// document.body.append(temp);
}
function a2(){
document.getElementById('source_text').value = '';
}
function a1(){
let message = document.getElementById('source_text')
// console.log(message.value)
let d = document.getElementById('source');
// console.log(d.value)
d.value = message.value;
}
(function() {
'use strict';
injectText();
var button_clear = document.getElementById('clear');
button_clear.onclick = a2;
var button_b = document.getElementById('my-trans');
// button_b.addEventListener('click',al);
button_b.onclick = a1;
// Your code here...
})();