0

I would like to change the text that will be pasted without changing the selection's appearance on the screen, similar to what the Linux xsel command can do.

Ideally this would work on all platforms and browsers, but at the very least I want it to work on Chrome running on Linux.

My usecase is that I have a button that selects a block of shell commands from the web page (this is done by some library magic that I have no easy access to) and I want to add a terminating newline "behind the scenes" so that when the user middle-clicks in the console, he gets the text that appears highlighted on the screen plus a newline.

How to do it?

Ari
  • 3,460
  • 3
  • 24
  • 31
  • And what is your question? Where are you stuck? – Rajesh Apr 19 '17 at 13:12
  • The question is how to do it. – Ari Apr 19 '17 at 13:28
  • See [this question](http://stackoverflow.com/questions/5379120/get-the-highlighted-selected-text) for how to get the selected text in a page. Then you just add a newline (\n or
    depending on how you want to use it).
    – GertG Apr 20 '17 at 08:03
  • How do I "just add a newline"? What I want to happen is that when the user pastes, the newline will be added to the pasted text. – Ari Apr 20 '17 at 12:21

0 Answers0