How do websites block selecting text and how do I unblock that?

75

20

There's a website (example) that somehow blocks selecting text. Also it blocks Ctrl+A to select everything, there is also no “Copy” in the popup menu.

What I have tried:

Some sites use JavaScript to block selection. So I disabled all JavaScript sources in no-script addon in Firefox. I tried the same site in Google Chrome with the Script Safe addon. Made sure that everything is blocked, still can’t select text. Mousepointer remains an arrow and not a text cursor also on the whole site.

Used about:config to disable JavaScript completely in Firefox. Still no effect.

I read that some sites use DIVs with the style display:block so I used Inspect to examine the styles of the site. There is not one mention of "block" on the whole website, not in embedded CSS nor in object style=-attributes.

The text is not an image or flash or some HTML5 canvas ect. Everything is within DIV and P tags but no style was found that might block the text selection.

How can the website still block any selection of text? Not to mention why browsers support such behaviours at all. I just want to use a selected word or sentence and want to search google for it using right mouse click. It’s pretty annoying when a website does such things and forces me to type technical terms and names into google by hand. It disturbs my workflow.

user6329530

Posted 2018-01-05T09:30:16.210

Reputation: 889

8"How do websites block marking of text" - They set style.userSelect to none. – None – 2018-01-05T09:52:20.030

1Do you want to duplicate the blocking on your own site? Or just copy this text? Look at the source & copy it from there yet? – Xen2050 – 2018-01-05T09:57:03.370

2@Xen2050 Mostly I don't care about copying text. I just love the ability to mark phrases and terms and search for it on Google with just a click of the mouse (doubleclick word, rightclick "Search Google..."). I could go into the source (if it's clean source at all) and scan for the word, copy it, paste in Google but well... as said this is just an annoyance. Some1 who wants to copy your website text can do it anyhow but someone who just wants a comfortable workflow gets hindered. – user6329530 – 2018-01-05T13:47:43.510

123Can we just take a moment and sympathize for all the delusional web developers out there who think this is a good security measure? – MCMastery – 2018-01-05T15:17:54.223

3I don't know how prevalent the practice is anymore, but I remember running across a few instances of a single-pixel image being stretched to cover the whole page to prevent copying of text etc. That and changing my mouse pointer to glittery rainbow-unicorn-stars along with flashing text everywhere... – RIanGillis – 2018-01-05T16:18:53.703

With JavaScript. Use Lynx as browser. – mirabilos – 2018-01-05T17:50:53.910

27@MCMastery Or worse, the developers who know it's terrible but are told they have to do it anyway. Most of the time they are worried about people stealing content. Then you've got sites like SO who are getting scraped/stolen from all the time... but commercially viable. Turns out alienating your userbase is bad for business. Who would have thought?! – corsiKa – 2018-01-05T20:39:16.193

1Install RightToCopy – Dmitry Kudriavtsev – 2018-01-05T20:47:47.787

There's a chrome addon that unblocks pasting, I'm sure there's one for unblocking selection and copying too. – Kevin – 2018-01-05T23:35:53.790

@mvw I think New York Times https://www.nytimes.com and Institutional Investor https://www.institutionalinvestor.com/ are additional example sites.

– Ellie Kesselman – 2018-01-07T16:05:21.713

2@MCMastery - the goal, as usual, is not to be faster than the dinosaur. The goal is to be faster than the dude next to you. Just as a goal of a lock isn't to defeat a burglar, it's to introduce more friction for them to go burgle someone else. Or in other words, the goal of the measure is not to introduce bulletproof security; it's to introduce enough friction to (a) deter casual copier and (b) make a less casual copier more interested in less-work-required-to-copy alternative sites. – DVK – 2018-01-07T21:12:35.470

@DVK +1000 for the much needed focus on real life. However part of the problem is that wishful thinkers often adopt this kind of measures and then expect these measures to "solve the problem", and if a developer humbly points out that they only make the content stealing require a bit more work, he/she is frowned upon as non-positive, not a doer etc. So it's still good that people point out that this approach is not a good security measure, they should just add something like "although it does mitigate the problem a lot". Then it depends on what level of protection the specific business needs. – SantiBailors – 2018-01-08T11:33:06.803

@MCMastery That's an awfully insular viewpoint. The correct assumption would be "Can we just take a moment and sympathize for all the delusional website owners out there who think their precious website content can be protected in any capacity whatsoever? And a moment of silence for the developer which was tasked in programming enough security to fool the owner." – MonkeyZeus – 2018-01-08T13:31:18.797

Answers

81

https://www.angst-panik-hilfe.de/angst-panik.css shows:

body{-webkit-user-select:none;-moz-user-select:-moz-none;
-ms-user-select:none;user-select:none}

So, that effect applies to the entire BODY tag.

Documentation on this CSS: Mozilla Developer Site: user-select.

You could probably override this by removing the style in Developer Tools (press F12 in Firefox or Chrome) - you may even be able to create a JavaScript applet that, after investing the time to set this up, can remove that style with less instant effort on your part (which may be a time saver if you plan to visit the site multiple times).

I'd also like to add this note: This might not be the only way to have at least some of that effect. Another possible way could be to have an invisible DIV cover the DIV that has the text. That way, the mouse cursor would not turn into the I-beam (text cursor) because the cursor would be based on the content of the top-most DIV. (Ctrl-A would probably cover that text, though.)

It's pretty annoying when a website does such things and forces me to type technical terms and names into google by hand. It disturbs my workflow.

Amen! Upon seeing this, I'm disappointed at the existence of such a CSS style being implemented by the major browsers. Such things are pretty annoying, indeed!

TOOGAM

Posted 2018-01-05T09:30:16.210

Reputation: 12 651

61The user-select CSS style is pretty helpful when applied responsibly. For instance, if you want (especially older) users on a touchscreen clicking on buttons near label text, you don't want them to mark the label text instead of clicking the button. – phihag – 2018-01-05T14:00:38.763

Thank you, @phihag, for the helpful other point of view. Still doesn't sway my disappointment seeing the major browsers implementing this as default behavior affecting my general computing (on a full-sized computer). Over the years, makers of major web browsers made other decisions I've disagreed with, and I've learned to accept the idea that they have some different opinions than I do. Even so, when I see them do things like (by default) taking control away from the user (and giving it to webmasters instead), my understanding of this reality doesn't mean I can't be still disappointed. – TOOGAM – 2018-01-05T15:14:38.657

14What do you mean "by default"? This setting is only enabled if the website specifically enables it, that doesn't sound like "by default" to me. There will always be features that can be misused by bad web designers, there's not much you can do to prevent that without negatively affecting those who do have a legitimate reason to use those features... – Sean Burton – 2018-01-05T15:18:20.650

1This should be quite easy in Greasemonkey – Chris H – 2018-01-05T15:22:25.307

1@TOOGAM It's not right to lay the blame at the "major browsers" for enabling it by default. The browser's job is to display/ perform whatever features it comes across in a page's code, not debate if it should be there or not. If you want to blame someone then you should probably point the finger at the restrictive design choices made by the dev's/designers and the way that they implement said features. – Sean T – 2018-01-05T16:10:18.437

1@SeanBurton if you view the webmaster as a "user" of a browser, then it makes sense to allow them to enable features. But if you view a browser as existing solely to serve the person looking at webpages, then it should be up to them as to whether a feature should be enabled. – Acccumulation – 2018-01-05T16:11:16.407

11@SeanT Again, if the browser exists to serve the person looking at webpages, then its job is to respond to what the web server sends however the user tells it to. If the user tells it to mute the page, or disallow pop-ups, or copy text, then the browser should do so. – Acccumulation – 2018-01-05T16:14:37.110

8No browser user is going to go to the bother of configuring their browser to explicitly enable a feature like this one, if it's not enabled by default then it's essentially useless and might as well not be implemented at all. And if you are suggesting that every feature must be explicitly enabled by the user, then where do you draw the line? Must the user enable the "images" feature before a website can display images? Must all browsers basically be Lynx by default until the user enables all the features they want? – Sean Burton – 2018-01-05T16:16:06.070

2@SeanBurton: Hey, Lynx has the "follow <a> tags when selected" and the "insert line breaks on <br>" features on by default. Its much better than this hypothetical browser. ;-) – Chris – 2018-01-05T16:21:52.353

13@Acccumulation The user-select: none feature is used all over the place to maintain the style of a webpage e.g, stopping an ugly blue background when selecting an option from drop down lists. You just don't notice because it's being implemented correctly. The problem here is that it's been implemented in a restrictive way to the user, and a browser has no way to differentiate between the two. Therefore, blame the dev's :) – Sean T – 2018-01-05T16:57:50.770

@SeanBurton First you say that this 'doesn't sound like "by default" to me', then you say that if it's not enabled by default then it's essentially useless. – Acccumulation – 2018-01-05T19:28:39.007

2Another way is to add onselectstart="return false;" to the body. Some other techniques (like, removing the selection with JavaScript) work as well. – Ismael Miguel – 2018-01-06T12:07:07.733

@SeanBurton: The line is drawn here: proper interface presumes that users have full control over how the browser renders things. Based on that line, disabling users from standard actions seems wrong. MS IE has an option about whether images are displayed, and *if* that is ever unchecked then, *yes*, the user must (re-)enable them. My thoughts about "by default" referred to the idea that Firefox and Chrome's built-in Dev Tools would allow the user to override the CSS, so disabling the user's ability to select is the default action (but can be overridden easily-ish, thanks to dev tools) – TOOGAM – 2018-01-06T13:33:33.043

1@SeanT - I view the browser's job as serving the user to let the user see rendered code in the way that the user desires. The web page's code instructs the browser what is desired, but the browser decides, and it is not the browser's job to perform whatever the page's code says, because the browser serves the user, not the web server (or webmaster/page designer). If a menu shows some unicode/emoji that I want to copy and paste into Google to find out the character's code, I don't like JavaScript/CSS trying to disable my ability to easily select text if that's what I'm trying to do. – TOOGAM – 2018-01-06T13:39:53.403

Oh, and to add to my last comment to @SeanBurton... At the time I said "by default" (but I forgot when I made my last comment), I was also thinking that in addition to Dev Tools, add-ons or Javascriptlets (bookmarks containing JavaScript code) could also be used (and would probably be a lot easier than Dev Tools). Kevin's comment in the question suggests such a thing (and reminded me). – TOOGAM – 2018-01-06T13:53:16.927

3Another detail is to keep in mind that HTML isn't just for web. There are plenty of games that use it for the interface, where selecting text doesn't make sense and where the user will click and drag the mouse for various reasons. – William Mariager – 2018-01-07T15:59:23.587

2

Well, this is what happens when the developer forgets to disable selection (that's a UI built with web technologies). If you want your app to feel like an actual app and not a text document, disabling selection is the way to go. But doing this on a website is a very poor design choice.

– Lucas Trzesniewski – 2018-01-07T20:25:19.317

@phihag Browsers already do this without CSS, links have a larger hit target than the link itself when touched. Sometimes to the point of being annoying and you have to zoom when you actually want to select text because the browser is trying to be too helpful. – Anders – 2018-01-08T02:22:06.500

13

As has already been stated, setting user-select: none in the page's CSS is what disables selection of text on a page. The easiest way to remove that text selection block would be through a user script like the following that overrides the setting:

// ==UserScript==
// @name         Force Select
// @version      1.0
// @description  Stop sites from disabling selection of text
// @author       You
// @match        *://*/*
// @grant        none
// ==/UserScript==

(function() {
  'use strict';

  let style = document.createElement('style');
  style.innerHTML = '*{ user-select: auto !important; }';

  document.body.appendChild(style);
})();

Note: This will apply to every page if left enabled, which might not be desirable in all situations.

The script can be installed and easily toggled on/off with a user script manager such as Violentmonkey, Tampermonkey, or Greasemonkey.

Herohtar

Posted 2018-01-05T09:30:16.210

Reputation: 527

9Worth mentioning you may need an extension such as 'greasemonkey' to add user scripts. – Stilez – 2018-01-07T14:27:35.443

1This will apply to every page if left enabled, which might not be desirable in all situations. Could you not just nest the function in an if statement that executes the script only if the URL matches a particular site or array of sites? – Hashim – 2018-01-09T03:33:28.680

1@Hashim That isn't necessary; you can specify which pages it applies to with one or more @match statements, but that would require modifying the script when you wanted it to apply to a specific page, unless you only visit a specific site or set of sites that you always want to modify. For the example script I made it generic by using *://*/* as the URL to match, so it will apply everywhere. It can be toggled on and off from the menu of the user script manager. – Herohtar – 2018-01-09T03:55:54.850

11

Open the developer tools (F12), change to the Elements tab, and untick the following CSS rules under body:

  • user-select: none;
  • webkit-user-select: none;

Demo Image

JMK

Posted 2018-01-05T09:30:16.210

Reputation: 2 839

7

With Firefox, there's a really easy way:

View > Page Style > No Style

In German:

Ansich > Webseiten-Stil > Kein Stil

enter image description here

It also works great to download embedded images on which right-click has been disabled.

Eric Duminil

Posted 2018-01-05T09:30:16.210

Reputation: 168

1Yeap, it works also on IE11. – Marco Demaio – 2018-02-20T13:37:46.433

4

You can hit Ctrl + P and grab what you need from the print preview.

enter image description here

Der Hochstapler

Posted 2018-01-05T09:30:16.210

Reputation: 77 228

3

I'm using Stylus (https://add0n.com/stylus.html) and I made a style to apply to all websites, and thus I am ensuring everything is selectable:

* {
  -webkit-user-select: auto !important;
  -moz-user-select: inherit  !important;
  -ms-user-select: inherit  !important;
  user-select: auto  !important;
}

The asterisk is to make sure the style is not only applied to a certain css element (like <body>), but to all elements. I encountered cases where the selection blocking was applied to a button text only, so making a css for <body> would not help.

I use selection for instant translation on foreign language websites.

derei

Posted 2018-01-05T09:30:16.210

Reputation: 31

I fixed the formatting and the visibility of the inline <body> tag; see https://superuser.com/help/formatting

– Arjan – 2019-01-07T15:10:36.380

0

I prefer using "bookmarklets" to user scripts or browser extensions. Try using one of the many bookmarklets to disable CSS & grab the required text

As it is may mess up the readability of web-page, I sometimes open the page in a different tab (right click on tab, select Duplicate) before removing the styling with the bookmarklet

You can also try the Google Mobilizer Bookmarklet to view just text of web pages

mvark

Posted 2018-01-05T09:30:16.210

Reputation: 2 260

0

As other answers have stated, its to do with the CSS on the body of the pages. Whilst you can edit this by hand every time, if you use this site a lot, I would suggest that if you use Chrome, you install the Stylish extension.

Stylish lets you create additional CSS to apply to pages. It can be used all over the web. It has the benefit of automatically applying whenever you visit the website (so you don't need to add it via the dev tools on every page load).

Once installed, click on the icon in the toolbar and select "Create New Style". It will automatically create the entry for the website you are currently visiting. You can then add any CSS you like to the page. But be warned: some styles may not be overriddable (especially if its written on the element itself, rather than a CSS class).

In this case, you can use the import function, and add the below code, this should allow you to select the text on the website you linked to.

@-moz-document domain("www.angst-panik-hilfe.de") {
  body {
    -webkit-user-select: auto !important;
    -moz-user-select: inherit  !important;
    -ms-user-select: inherit  !important;
    user-select: auto  !important;
  }
}

Obsidian Phoenix

Posted 2018-01-05T09:30:16.210

Reputation: 217

Adding webkit and ms prefixes for something that will only run on firefox is a bit... redundant. – Stephan Bijzitter – 2018-01-08T12:31:42.667

@StephanBijzitter True, I just overwrote all the styles relating to user-select already on the page. But then again, it does mean that someone not using chrome but with a similar extension could fairly easily copy this class and gain the same benefit without work - and it doesn't really harm the solution. – Obsidian Phoenix – 2018-01-08T12:33:38.233

0

Several of the solutions proposed might be browser specific, so it's worth suggesting a few alternatives:

  1. Use a broswer that respects you more.

    a. Emacs has browsers emacs-w3m and eww that will always allow one to select text.

    b. Other text-based browsers such as lynx, elinks, and w3m, might allow one to select text, but even if not, if running those programs in a terminal window, one can select text using one's mouse. And, if one is using those programs from within tmux, one can use tmux's ability to copy text even without a mouse.

  2. Use a command line tool to download the entire url in a readable text format.

    a. w3m -dump [your_url] > your_file.txt

    b. lynx -dump [your_url] > your_file.txt. I usually prefer this one because it marks hyperlinks as readable footnotes!

user1404316

Posted 2018-01-05T09:30:16.210

Reputation: 113

0

Install the AddOn "Absolute Enable Right Click & Copy", that enables everything that the other No Script AddOns can not.

Chris

Posted 2018-01-05T09:30:16.210

Reputation: 1

0

Just create the following css style:

html, body {
    user-select: text;
}

There is an extension called Stylish which allows you to install that (or any other) css code in any website of your choice. Just type in the above css code and tell which website[s] you want it to be applied to and you are good to go. This extension works on Chrome, Baidu, Firefox and Opera. If you happen to be on IE then you are out of luck. But you already know that don't you.

agcala

Posted 2018-01-05T09:30:16.210

Reputation: 103

0

Another possibility to deactivate the selection is to use the property onselectstart, as explained by Ismael Miguel:

Another way is to add onselectstart="return false;" to the body. Some other techniques (like, removing the selection with JavaScript) work as well. – Ismael Miguel Jan 6 '18 at 12:07

Via the Developer Tools of Chrome, I could dynamically remove the selectstart event handler and then could select the text (and hopefully use Ctrl+C which was not disabled).

Sandra Rossi

Posted 2018-01-05T09:30:16.210

Reputation: 103