Google Translater Formatter

Used to fomat text in google translation

Verze ze dne 02. 11. 2019. Zobrazit nejnovější verzi.

// ==UserScript==
// @name         Google Translater Formatter
// @namespace    http://tampermonkey.net/
// @version      1.0.0
// @description      Used to fomat text in google translation
// @author       Shi Fan
// @include         https://translate.google.*/
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
    setTimeout(function(){
        var element = document.querySelector('div.tlid-input-button-container');
        element.innerHTML += '<div class="input-button header-button" role="tab" tabindex="-1" style="background-color: #ffcdd2; border-color: #e57373; padding-left: 16px; color: black"><div class="text">重新排版</div></div>';
        element.addEventListener("click", function() {
            var input = document.querySelector('textarea.goog-textarea');
            var text = input.value.replace(/\n/g, ' ');
            console.log(text);
            input.value = text;
        }, false);
    }, 500);

})();