Skip to content

Instantly share code, notes, and snippets.

@feihong
Created May 21, 2015 18:40
Show Gist options
  • Save feihong/54ba2969866f9065016d to your computer and use it in GitHub Desktop.
Save feihong/54ba2969866f9065016d to your computer and use it in GitHub Desktop.
Copy Crowdin phrases to clipboard
// ==UserScript==
// @name Copy Crowdin text to clipboard
// @namespace https://github.com/feihong/
// @description Copies the source and translation phrase to the clipboard.
// @include https://crowdin.com/translate/*
// @version 1
// @grant GM_setClipboard
// ==/UserScript==
var menu = document.querySelector('#editor-menu');
var li = document.createElement('li');
li.style = "color: white; padding-top: 6px; cursor: pointer;";
li.innerHTML = 'Copy';
menu.appendChild(li);
li.onclick = function() {
var sourcePhrase = document.querySelector('#source_phrase_container').textContent;
var translationPhrase = document.querySelector('#translation').value;
var result = sourcePhrase + '\n' + translationPhrase;
// alert(result);
GM_setClipboard(result);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment