Last active
October 14, 2018 02:19
-
-
Save flarn2006/a20600f2d89722837248389ba2c5355a to your computer and use it in GitHub Desktop.
Reverse text button for Google Translate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Google U.G.E. | |
// @version 1.1 | |
// @grant none | |
// @include https://translate.google.com/* | |
// ==/UserScript== | |
window.addEventListener('load', function() { | |
var btn = document.createElement('div'); | |
btn.setAttribute('class', 'jfk-button-standard jfk-button-narrow jfk-button'); | |
btn.setAttribute('role', 'button'); | |
btn.setAttribute('data-tooltip', 'Reverse characters'); | |
btn.style.float = 'right'; | |
btn.innerText = 'cbA'; | |
var source = document.getElementById('source'); | |
btn.addEventListener('click', function() { | |
var newStr = ''; | |
for (var i=source.value.length-1; i>=0; --i) { | |
newStr += source.value[i]; | |
} | |
source.value = newStr; | |
}); | |
var gtswap = document.getElementById('gt-swap'); | |
gtswap.parentNode.appendChild(btn); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment