How can I stop JavaScript from modifying the clipboard?

13

4

More and more I find that when I copy text from a news site, the site adds in its own advertising/footnote link to my clipboard, so that when I paste, the copied text is appended with something like:

[Text I copied] FOR MORE, GO READ AT http://www.example.com/link/to/story

I admire the technical abilities that made this possible, but I would like to stop it on my browser. I looked through about:config for "clipboard" and "copy," but the only setting I found was autocopy on highlight.

Is there a good way to stop this so that when I copy I get only the text I highlighted, relying only on Firefox's built-in copy feature and not triggering anybody's JavaScript or other site customizations? I don't like sites telling my browser how to work.

As an example, copy one of the fun "facts" here - when you paste, you'll have the following text appended:

Read more: http://www.linuxscrew.com/2007/10/28/fun-chuck-norris-vs-linus-torvalds/#ixzz1mUKtACkt

They aren't just hijacking the control-C keystroke, I get it when I select "copy" from the right click menu, as well.

I would like my browser to completely ignore this trick.

I replicated this on Firefox, IE, and Google Chrome.

skiphoppy

Posted 2012-02-13T17:01:00.350

Reputation: 2 193

1I think that IE doesn’t do that. – kinokijuf – 2012-02-13T17:25:13.090

2Are you pressing [Ctrl]+[C] to copy? The system's copy hotkey may be getting intercepted by JavaScript and setting Selecton+Junk to the Clipboard. A more likely case is that there is hidden text (via CSS) that is being included in your selections. If you include a link to such an article, we can examine it and find a workaround or solution to this horrible practice. – iglvzx – 2012-02-13T23:59:03.523

Further reading: http://daringfireball.net/2010/05/tynt_copy_paste_jerks

– Josh Lee – 2012-02-27T16:23:11.160

Answers

5

It turns out this JavaScript code is being served by a "service" called tynt.com. Redirecting tcr.tynt.com to 127.0.0.1 in my hosts file solved the problem for me. From what I read elsewhere, there may be multiple servers that need to be blocked. Adblock list subscriptions may also take care of the problem, and you may be able to set up a filter in your ad blocking software to correct it.

What I would really like would be a flag in about:config to remove permission for JavaScript to modify the clipboard.

skiphoppy

Posted 2012-02-13T17:01:00.350

Reputation: 2 193

7

To disable this behavior in Firefox:

  1. In the URL bar, type: about:config
  2. Press Enter
  3. In the search box, type: dom.event.clipboardevents.enabled
  4. Double-click it to toggle its value to false.

Mike

Posted 2012-02-13T17:01:00.350

Reputation: 71

Doesn't seem to work for me in Firefox 68.0.1. – Per Lundberg – 2019-08-28T12:34:26.717

0

What you describe only happens when I select one of the advertisement links that is underlined in green:

Advertisement Link

So when you copy that, nobody is hi-jacking your clipboard. You're copying the hyperlink from the website.

To prevent these links from being inserted into the website, look into advertisement blocking solutions for your browser.

Der Hochstapler

Posted 2012-02-13T17:01:00.350

Reputation: 77 228

2No, I am afraid it happens on every line. However, I've discovered it may be blocked by some ad blocking lists. – skiphoppy – 2012-02-15T22:03:20.880

I tried it with Firefox, Chrome and IE. They all showed the same behavior. I assume where the links are placed and how they look might even differ between instances. – Der Hochstapler – 2012-02-15T22:56:10.390

1Did you read the answer I gave about tynt? Apparently tynt is mercifully blocked on your machine or network. It was for a coworker of mine, too. The behavior I was getting was totally different from what you describe. I was getting text inserted, the words "Read more:", not just a hyperlink. – skiphoppy – 2012-02-17T14:23:11.633