38

There are many sites that insert something like "Read more: www.site.com" into your clipboard when you copy text in your browser. I find this abominable. A Google earch reveals some methods to stop this if the website happens to be using the service Tynt (by just blocking the Tynt domain), but many websites use home-grown JavaScript.

Is there a general way to block this behavior besides just turning off JavaScript? I use Chrome, but I am interested in all solutions.

To be clear, I want to be able to keep the rest of the JavaScript functionality for these websites, since many will break without it.

Here are two example websites which continue to harass me despite my use of a Tynt blocker: Marginal Revolution | The Fiscal Times

Here are two Stack Overflow questions and two blog posts which explain ways to implement this shady practice manually without Tynt. Here is a blog post describing how hard this turns out to be to block reliably. Here is the most recent discussion I could find (March 2013) which offers suggestions on how to block this in Chrome using Adblock, but it didn't work for me.

1
  • Second link: It says "We've Moved!" Jun 18, 2022 at 9:40

6 Answers 6

32
+50

The site adding the annoying "Read more" stuff is ShareThis.

To prevent this bad behavior, you have three different alternatives:

Disable the clipboard events

These websites are using the Clipboard APIs, which allows web developers to intercept the copy/cut/paste actions and execute some code when they are performed. This is how ShareThis (and other websites like that) works. It simply waits for the copy event and right before the effective copy is performed it adds an additional "layer" of text which contains the annoying "- See ...".

Now the question is: is there any kind of method to disable the clipboard events? Unfortunately, I have not been able to find a method to do this in Chrome/Chromium, but in Firefox it's possible in two different ways.

  • Go in about:config and search for dom.event.clipboardevents.enabled. Double click on the key (set it to false) and voila! You have disabled the clipboard events and no one will touch your clipboard again.
  • For older versions of Firefox (really, really older), there is this extension which does the exact same thing of the about:config option.

Disabling clipboard events should not damage the experience of any website since they are rarely used and there isn't really a purpose to use them (other than spamming).

Let's head over to the second solution.

Block ShareThis

If you don't need ShareThis, you can simply block the w.sharethis.com domain. The Javascript responsible for loading ShareThis (and registering the ClipboardEvent) is loaded from that website.

You may block it in different ways, ranging from a simple Adblock filter to editing your hosts file (this is not covered nor linked here since I can't put more links due to my reputation).

An example of doing that via the hosts file:

127.0.0.1 w.sharethis.com

The third solution is the hardest one and it should be used only as a last resort.

Disable the selection feature on the problematic websites

To edit the content which is copied to the clipboard, these websites use the Selection API which allows them to edit selections on-the-fly. So, a solution is to completely disable any kind of Selection (on the code-side, obviously. You will still be able to perform selections).

This can be done with a simple Tampermonkey or Greasemonkey script. I tested it only on Firefox since I can't install Chrome right now. I'm sorry for that.

This is the source code:

// ==UserScript==
// @name        Goodbye selections
// @namespace   tag: utils
// @include     $put_here_a_website_you'd_like_to_disable_selections$
// @include     $more_websites$
// @version     1
// @grant       none
// ==/UserScript==
(function() {
    var disableSelections = function() {
        document.getSelection = window.getSelection = function() {
            return { isCollapsed: true };
        };
    };
    var script = document.createElement ("script");
    script.appendChild (document.createTextNode ("(" + disableSelections + ")();"));
    (document.body || document.head || document.documentElement).appendChild (script);
})();

To let this work, you should create a new Greasemonkey or Tampermonkey script and adjust the @include directives. You can put one website per line, and it has to be done like @include http://bad.website.address/.

I tested it with both the websites you have linked and it works with no problems. However, keep in mind that this may cause problems since Selections are used by perfectly legit websites (for example, Stack Exchange textboxes use them to insert a symbol, when you click on the button, to the position of your caret), so you should enable that userscript only on problematic websites.

(Note that you may need to remove the lines starting with // if you are creating the userscript from the Greasemonkey or Tampermonkey menus, they will automatically add it.)

The explanation of the userscript is pretty simple. First, it defines a function named disableSelections which replaces the default document.getSelection and window.getSelection functions with one that simply returns an object containing { isCollapsed: true }. Why? Because ShareThis (I checked in their JavaScript code) calls that function and checks if the isCollapsed property is set to true (if it is, it stops the "clipboard poisoning"). Other websites like that maybe won't perform that check, but they will end up simply with an error when they try to call a legit function of the Selection object.

Then the function is injected in the body/header/document and it will be automatically executed. A question you may ask is: if JavaScript allows to override (almost) every function, why didn't you override the addEventListener function to simply do nothing when the event is copy/cut/paste? The answer is pretty simple. An userscript is executed at a non-easily-predictable time, this means that the ShareThis JavaScript code can be loaded before the userscript, and it won't do anything. Instead, by just overriding the window.getSelection function there won't be any problem since that function is called only when a copy is performed, and we are 100% sure that when you copy a text, the userscript has already been loaded.

Conclusion

The best and cleanest solution is obviously the first one, since it disables a practically useless API.

The second one is valid too, but you will lose any of the ShareThis functionality.

The third one is the most "hacky" one, but as a last resort it could work.

5
  • Thank you very much! This is excellent. It's a shame that this is so difficult and has no perfect solution, but your answer appears to be the best information that is currently available on the internet. Very pleased to award you the bounty. Jan 29, 2014 at 18:49
  • Yeah, I did quite a bit of research since that problem was affecting me as well. Thank you for the bounty by the way - this will help my "newcomer" StackExchange experience!
    – Robertof
    Jan 29, 2014 at 18:55
  • Re: the first one, does this block sites where you can click a button to copy some text? E.g., emojipedia.org/snowman . Empirically, in Firefox, it does not seem to. Cool. Re: blocking ShareThis, my debugger is now showing the scripts loading from the subdomains "l.sharethis.com" and "ws.sharethis.com". So I think the only full cure is blocking the full ShareThis.com domain, which should be no great loss. Thanks @Robertof! Jan 10, 2019 at 19:53
  • 1
    Caution: disabling clipboard events can cause some sites to malfunction. For example, it causes Discord to crash when pasting into search.
    – Nicholas
    Aug 26, 2019 at 14:34
  • I dont think the first solution is possible anymore, couldn't find dom.event.clipboardevents.enabled Oct 6, 2023 at 22:20
3

These odious actions can be blocked on Chrome with the "Kill Evil" extension:

https://chrome.google.com/webstore/detail/kill-evil/epieehnpcepgfiildhdklacomihpoldk

This extension appears to cause weird issues on Facebook, so be sure to whitelist it.

5
  • Excellent! I've found three extensions which purport to solve this problem: 1. Tynt Blocker. 2. RightToCopy. 3. Kill Evil (thanks to you, seagull). Kill Evil is the one that worked to fix the especially nasty clipboard manipulations at phys.org, Mar 7, 2017 at 23:01
  • 1
    no worries @DaveBurton – please do note that this extension causes many sites to behave rather strangely, though, so only enable it when you need it.
    – seagull
    Mar 8, 2017 at 12:58
  • 2
    Kill Evil supports an exclusion list or "whitelist," which is a list of sites for which you do NOT want the extension enabled (i.e., a "permit evil" list). That wasn't what I wanted: I just want to enable Kill Evil ONLY on a particular site (phys.org). So I ended up with this tricky "negative lookahead" regular expression, to disable Kill Evil except for that one site: ^https?:\/\/(?!([a-zA-Z0-9\-\.]*phys\.org)) Apr 25, 2017 at 21:08
  • Love a cheeky bit of regex. Thanks for posting it.
    – seagull
    Apr 27, 2017 at 8:10
  • 1
    The link is broken (404). Jun 18, 2022 at 9:51
2

On Chromium I had success with Absolute Enable Right Click & Copy extension.

Having installed it, you can add you user list of sites where the extension is enabled in the preferences. Or, when you are on a particular page and see that it tampers with your clipboard, you can enable this extension on the fly via its toolbar button (this automatically adds the site to your list).

1

Although it is a Firefox addon, NoScript allows you to block JavaScript from any website by setting up an untrusted list.

1
  • 2
    Thanks for the answer, but this isn't what I need. (I want something that doesn't break JavaScript everywhere on the site.) I'll edit the question to be more specific. Jan 22, 2014 at 0:41
1

If you are looking for a way to automatically modify the HTML before it is displayed, then Greasemonkey is the tool, and you would need to create a user-script that that does the modification.

From the article Beginner Guide for Greasemonkey Scripts in Google Chrome :

Chrome now natively supports user scripts. You don’t have to install an extra extension to use them; in fact, Chrome treats each user script as an individual addon so you can easily manage and remove them.

There is a lot of information about Greasemonkey to be found on the Internet, including many tutorials. Most of them would be for Firefox, where Greasemonkey originated, but they also apply today to Chrome.

As the site responsible for the "Read more" is sharethis.com. If you block it, this should stop. If you have an installed security suite, use it to block the site. Otherwise you can block it using your hosts file.

sharethis.com is the provider that supplies Tynt to the two websites you gave me. Tynt looks to be rather a technology than a website, so there may of course be other such providers, But one has to hope that they would be rather rare.

8
  • OK, thanks. In principle just about anything on a website can be fixed if one applies a greasemonkey script. (At the least, I presume any JavaScript problem can be fixed by more JavaScript.) In order to accept this answer for the bounty, I'd need a lot more info on how to implement it. Jan 22, 2014 at 20:53
  • What kind of info? One can start with wikipedia that gives the most important links including the wiki and userscripts.org.
    – harrymc
    Jan 23, 2014 at 6:47
  • Say, an explanation of how the non-Tynt implementations work and what exactly would be done about them? So far nothing you've written is even specific to this copy-paste problem (rather than JavaScript in general). Jan 23, 2014 at 15:57
  • I have never met Tynt (no wonder since I use NoScript). From the two example websites in the article you linked-to, one has disappeared and the other doesn't use Tynt any more. Do you have an example?
    – harrymc
    Jan 23, 2014 at 18:54
  • I have made an edit to add two example websites that continue to have this behavior even when I use a Tynt-blocking extension. Jan 25, 2014 at 18:34
0

Alternatively, use the "Copy as Plain Text" extension for Chrome. You then have an additional option in the menu besides normal copying. It has the upside that it works in Chrome and doesn't break anything.

1
  • From the name, you would think it breaks copying formatted text? That's sometimes useful to some people. Jan 10, 2019 at 19:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .