Skip to content

Instantly share code, notes, and snippets.

@nkmathew
Created April 22, 2017 15:08
Show Gist options
  • Save nkmathew/5fba5c9ff2bc0dea8f6df25b9e1c29f8 to your computer and use it in GitHub Desktop.
Save nkmathew/5fba5c9ff2bc0dea8f6df25b9e1c29f8 to your computer and use it in GitHub Desktop.
Adds a button for copying text from the translation source inputbox in Google Translate
// ==UserScript==
// @name Google Translate Copy Button
// @namespace http://nkmathew.net/
// @version 0.1.0
// @description Adds a button for copying text from the translation source inputbox in Google Translate
// @icon http://translate.google.com/favicon.ico
// @icon64 http://translate.google.com/favicon.ico
// @author nkmathew
// @match https://translate.google.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
var copyButton = document.getElementById('gt-res-copy').cloneNode(true);
var srcToolbar = document.getElementById('gt-src-tools-l');
copyButton.classList.add('goog-toolbar-button-hover');
copyButton.style.display = 'block';
srcToolbar.appendChild(copyButton);
document.querySelector('.copy-button').addEventListener('click', function(event) {
document.getElementById('source').select();
document.execCommand('copy');
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment