Skip to content

Instantly share code, notes, and snippets.

@Aero-Blue
Created July 31, 2019 16:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Aero-Blue/32b0de4813e50a6dec6bdd1dc3d54796 to your computer and use it in GitHub Desktop.
Save Aero-Blue/32b0de4813e50a6dec6bdd1dc3d54796 to your computer and use it in GitHub Desktop.
Automatically copies selected Bitcoin addresses to clipboard!
// ==UserScript==
// @name EasyCopyBTC
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Automatically copies selected Bitcoin addresses to clipboard!
// @author Aero Blue
// @match *://*/*
// @grant none
// ==/UserScript==
function getSelectedText() {
var text = "";
if (typeof window.getSelection != "undefined") {
text = window.getSelection().toString();
} else if (typeof document.selection != "undefined" && document.selection.type == "Text") {
text = document.selection.createRange().text;
}
return text;
}
function copyToClipBoard() {
var selectedText = getSelectedText();
if (/^([13][a-km-zA-HJ-NP-Z1-9]{25,34}|bc1[ac-hj-np-zAC-HJ-NP-Z02-9]{11,71})$/.test(selectedText) == true) {
document.execCommand("copy");
}
}
document.onmouseup = copyToClipBoard;
document.onkeyup = copyToClipBoard;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment