chrome bookmarklet copy text

Solutions on MaxInterview for chrome bookmarklet copy text by the best coders in the world

showing results for - "chrome bookmarklet copy text"
Bev
26 Feb 2016
1// This needs to be minified (and prefixed) to work
2// I just put the full function here to better show what the code is doing
3
4// Use the bottom line of code and replace "Text To Copy" with your own
5// text and you're good to go! 
6
7(function (text) {
8  var node = document.createElement('textarea')
9  var selection = document.getSelection()
10
11  node.textContent = text
12  document.body.appendChild(node)
13
14  selection.removeAllRanges()
15  node.select()
16  document.execCommand('copy')
17
18  selection.removeAllRanges()
19  document.body.removeChild(node)
20})('Text To Copy')
21
22// here is the minified:
23javascript:!function(a){var b=document.createElement("textarea"),c=document.getSelection();b.textContent=a,document.body.appendChild(b),c.removeAllRanges(),b.select(),document.execCommand("copy"),c.removeAllRanges(),document.body.removeChild(b)}("Text To Copy");