Answers for "chrome bookmarklet copy text"

0

chrome bookmarklet copy text

// This needs to be minified (and prefixed) to work
// I just put the full function here to better show what the code is doing

// Use the bottom line of code and replace "Text To Copy" with your own
// text and you're good to go! 

(function (text) {
  var node = document.createElement('textarea')
  var selection = document.getSelection()

  node.textContent = text
  document.body.appendChild(node)

  selection.removeAllRanges()
  node.select()
  document.execCommand('copy')

  selection.removeAllRanges()
  document.body.removeChild(node)
})('Text To Copy')

// here is the minified:
javascript:!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");
Posted by: Guest on June-07-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language