71

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.

  • 8
    "How do websites block marking of text" - They set style.userSelect to none. – user766703 Jan 5 '18 at 9:52
  • 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. – bxyify Jan 5 '18 at 13:47
  • 122
    Can we just take a moment and sympathize for all the delusional web developers out there who think this is a good security measure? – MCMastery Jan 5 '18 at 15:17
  • 3
    I 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 Jan 5 '18 at 16:18
  • 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 Jan 5 '18 at 20:39

11 Answers 11

80

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!

  • 61
    The 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 Jan 5 '18 at 14:00
  • 14
    What 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 Jan 5 '18 at 15:18
  • 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 Jan 5 '18 at 16:14
  • 8
    No 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 Jan 5 '18 at 16:16
  • 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 Jan 5 '18 at 16:57
11

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.

  • 9
    Worth mentioning you may need an extension such as 'greasemonkey' to add user scripts. – Stilez Jan 7 '18 at 14:27
  • 1
    This 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 Jan 9 '18 at 3:33
  • 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 Jan 9 '18 at 3:55
10

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

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.

  • 1
    Yeap, it works also on IE11. – Marco Demaio Feb 20 '18 at 13:37
2

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

enter image description here

1

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.

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

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;
  }
}
  • Adding webkit and ms prefixes for something that will only run on firefox is a bit... redundant. – Stephan Bijzitter Jan 8 '18 at 12:31
  • @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 Jan 8 '18 at 12:33
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!

0

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

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.