3

Some websites insist on ruining usability and accessibility by disabling the ability to select text on the page. Sites can do this via CSS or JavaScript (example page).

Is there some way that this can be disabled in Firefox so that the user can always select text no matter how the web page tries to disable it?

Disabling JavaScript globally is not a solution as it breaks many websites.

sleske
  • 22,652
  • 10
  • 69
  • 93
WackGet
  • 752
  • 2
  • 13
  • 28
  • You write of "highlighting" text in a page. I assume you refer to *selecting* text (with mouse, finger etc.)? Many browser do highlight text you selected in some way, but the user action is "selection". I edited to clarify - feel free to re-edit to correct. – sleske Apr 04 '20 at 18:27

2 Answers2

2

First, good question - I also notice this and it hugely annoys me.

The solution will depend on how the site disables text selection. As you write, this can be done using either CSS or JavaScript.

Disabled via CSS

The site most likely uses the CSS propert "user-select". user-select: none; will disable text selection.

To fix this, you would have to change the CSS styling the site uses. This can be done by running this small JavaScript snippet:

document.styleSheets[0].insertRule("* { user-select:text !important }", 1);

This will insert a new CSS rule that overrides the "user-select" setting of the page.

To run this: Either paste it into the JavaScript console of your browser's developer tools (and press enter), or use a userscript manager .

Disabled via JavaScript

This is probably trickier, because there are multiple ways of doing this. Most involve registering an event handler for mouse or selection events, but there are multiple events and multiple ways of registering them, so it's hard to give a general rule.

The pragmatic solution probably would be to temporarily disable JavaScript.

However, most sites I have seen that disable selection do it via CSS nowadays.

sleske
  • 22,652
  • 10
  • 69
  • 93
  • Thanks for your reply. Did you check out my [example page](https://foodhub.co.uk/ordernow/ba-shu/london/4020125)? It seems to use JavaScript, not CSS, though I may be wrong. – WackGet Apr 05 '20 at 20:48
  • Well, did you try my answer? ;-) I tested it on your example page, and it worked for me (i.e. text was selectable afterwards). – sleske Apr 05 '20 at 21:36
  • Tested and working in both Firefox and Google Chrome. – sleske Apr 06 '20 at 09:22
0

To avoid typing the code into the console, you can use a bookmarklet. Create a bookmark with the the following code at the place of the URL:

javascript:(function(){javascript:document.styleSheets[0].insertRule("* { user-select:text !important }", 1);})();
Erik
  • 1