Created
July 31, 2019 16:27
-
-
Save Aero-Blue/32b0de4813e50a6dec6bdd1dc3d54796 to your computer and use it in GitHub Desktop.
Automatically copies selected Bitcoin addresses to clipboard!
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 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