website will not allow text selection

Users and developers helping users with generic and technical Pale Moon issues on all operating systems.

Moderator: trava90

Forum rules
This board is for technical/general usage questions and troubleshooting for the Pale Moon browser only.
Technical issues and questions not related to the Pale Moon browser should be posted in other boards!
Please keep off-topic and general discussion out of this board, thank you!
ltcomdata
Moon lover
Moon lover
Posts: 79
Joined: 2015-06-28, 03:49
Location: WI

website will not allow text selection

Post by ltcomdata » 2025-11-05, 07:37

Operating system: Windows 11
Browser version: 33.9.1
32-bit or 64-bit browser?: 64-bit
Problem URL: https://canonlawmadeeasy.com/
If possible, please include the output of help->troubleshooting information (as text): None.

For some reason I am unable to select (or copy) text on this webpage.
Perhaps that is the intention of the author, and they are somehow able to force this restriction on visitors?
Is there a way around that?

Thanks!

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 38483
Joined: 2011-08-28, 17:27
Location: Sweden

Re: website will not allow text selection

Post by Moonchild » 2025-11-05, 08:08

ltcomdata wrote:
2025-11-05, 07:37
For some reason I am unable to select (or copy) text on this webpage.
Perhaps that is the intention of the author, and they are somehow able to force this restriction on visitors?
Correct. The author has blanket-denied selection of anything by the user through CSS. They also went out of their way to try and disable browser context menus and even to try and block screenshots (unfortunately for them, that particular attempt doesn't work in Pale Moon ;)).

Workaround: Press F12 to open up the devtools, go to inspector, select the "select element" tool (left in toolbar) and click on the text for quick selection of a useful element, then uncheck the rules for "user-select" highlighted in the screenshot below, and you can select and copy (with keyboard) text.
You do not have the required permissions to view the files attached to this post.
"There is no point in arguing with an idiot, because then you're both idiots." - Anonymous
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

User avatar
tellu-white
Lunatic
Lunatic
Posts: 270
Joined: 2022-03-08, 22:02

Re: website will not allow text selection

Post by tellu-white » 2025-11-05, 11:15

ltcomdata wrote:
2025-11-05, 07:37

Problem URL: https://canonlawmadeeasy.com/

For some reason I am unable to select (or copy) text on this webpage.
Perhaps that is the intention of the author, and they are somehow able to force this restriction on visitors?
Is there a way around that?

Thanks!
A long time ago, I made a Custom Button to solve this problem. I haven't checked the code since then, since it works.

Custom Button code ( "CODE" + "Initialization Code" - see Screenshot ) :

Code: Select all


// Name: Enable Copy with Right-Click


///////////////////////////////////////////////////////////  CODE  ////////////////////////////////////////////////////////////

var prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);

// Remove ALL "script" and "style" TAGs from HEAD

var head_tag = content.document.getElementsByTagName("head")[0];		
var all_head_tags = head_tag.getElementsByTagName("*");

var index_tag = all_head_tags.length - 1
							
while(all_head_tags[index_tag]){
	var tagName = all_head_tags[index_tag].tagName;
	
	if((tagName == "SCRIPT") || (tagName == "STYLE")){
		all_head_tags[index_tag].parentNode.removeChild(all_head_tags[index_tag]);
	}
	
	index_tag--;
}

// Remove ALL "script" and "style" TAGs from BODY

var body_tag = content.document.getElementsByTagName("body")[0];		
var all_body_tags = body_tag.getElementsByTagName("*");

var index_tag = all_body_tags.length - 1
							
while(all_body_tags[index_tag]){
	var tagName = all_body_tags[index_tag].tagName;
	
	if((tagName == "SCRIPT") || (tagName == "STYLE")){
		all_body_tags[index_tag].parentNode.removeChild(all_body_tags[index_tag]);
	}
	
	index_tag--;
}

function enable_copy_with_right_click(evt) {
	evt.stopPropagation();
	
	window.addEventListener('contextmenu', function(evt){enable_copy_with_right_click(evt)}, false);
	window.addEventListener('copy', function(evt){enable_copy_with_right_click(evt)}, false);
	window.addEventListener('cut', function(evt){enable_copy_with_right_click(evt)}, false);
	window.addEventListener('paste', function(evt){enable_copy_with_right_click(evt)}, false);
}

// Adds CSS rules to undo user-select:none

// https://github.com/alanhogan/bookmarklets/blob/master/enable-text-selection.js

/**
 * 	Adds CSS rules to undo user-select:none.
 * 	Also cycles through every child of <body> and binds events associated with text selection to a benign function.
 * 	Finally, remove 'disabled' attributes from all text inputs and ensures that keydown and keyup events are allowed
 * 	( to defeat blocks that prevent cut, copy, paste using shortcuts ).
 * 	There is one concern though: binding to so many events will undoubtedly break functionality on some pages.
 * 	For instance, text inputs very often have custom events bound to keypresses ( eg. to run a search and show results as the user types ).
 * 	As a result, this script is probably not fit to run indiscriminately on all pages.
 * 	It should rather be used only when the user needs to defeat text-selection blocks on specific pages.
*/

function allowTextSelection() {
	// Add styles that enable text selection
	
	var style = content.document.createElement("style");
	style.type = "text/css";
	style.innerHTML = 	`*, p, div {
							user-select: text !important;
							-moz-user-select: text !important;
							-webkit-user-select: text !important;
							-khtml-user-select: text !important;
							-ms-user-select: text !important;
						}
						*::selection {
							background: #3399ff; color: #ffffff;
						}
						*::-moz-selection {
							background: #3399ff; color: #ffffff;
						}
						*::-webkit-selection {
							background: #3399ff; color: #ffffff;
						}`;

	window.content.document.head.appendChild(style);

	// Put all of <body> children in a collection
	// Use getElementsByTagName because it has better compatibility ( it's older ) than querySelectorAll('*')
	
	var elArray = window.content.document.body.getElementsByTagName("*");

	// Allow mouse events typically involved in selection
	
	for (var i = 0; i < elArray.length; i++) {
		var el = elArray[i];
		el.onselectstart = el.ondragstart = el.ondrag = el.oncontextmenu = el.onmousedown = el.onmouseup = function() {
			return true;
		};

		// Special processing for text-style <input> elements
		
		if ( el instanceof HTMLInputElement && ["text", "password", "email", "number", "tel", "url"].indexOf( el.type.toLowerCase() ) > -1 ) {
			
			// Enable text inputs (to defeat an easy way to block selection by setting input's 'disabled' attribute)
			
			el.removeAttribute("disabled");

			// Counteract any listener that would block copy&paste keyboard shortcuts
			// ( I can't figure out yet why although this works on the first text input in text-selection-demo.html, it doesn't work on the 2nd ).
			
			el.onkeydown = el.onkeyup = function() {
				return true;
			};
		}
	}
}

// Modify a property of External CSS file

// getStyleSheet('https://www.devicespecifications.com/css/style.css?69f56c4dae64ea5633be0eb803b690b3', 'body').style.MozUserSelect = "text";

// https://stackoverflow.com/questions/33784443/how-modify-a-property-of-external-css-file-using-jquery-javascript

function getStyleSheet(cssName, rule) {
	var return_value = null;
	
	try{
		for (i = 0; i < content.document.styleSheets.length; i++) {
			if (content.document.styleSheets[i].href.toString().indexOf(cssName) != -1){
				for (x = 0; x < document.styleSheets[i].rules.length; x++) {
					if (content.document.styleSheets[i].rules[x].selectorText){
						if (content.document.styleSheets[i].rules[x].selectorText.toString().indexOf(rule) != -1){
							return_value = content.document.styleSheets[i].rules[x];
							
							return return_value;
						}
					} else {
						return return_value;
					}
				}
			}
		}
		
	} catch(err){
		// alert(err.message);
	}
	
	return return_value;
}

var current_location = window.content.document.location.href;

if(window.content.document.location.href == current_location) {
	/////////////////////////////////////////////////////////////////////////////////////////////////////
	
	window.addEventListener('contextmenu', function(evt){enable_copy_with_right_click(evt)}, true);
	window.addEventListener('copy', function(evt){enable_copy_with_right_click(evt)}, true);
	window.addEventListener('cut', function(evt){enable_copy_with_right_click(evt)}, true);
	window.addEventListener('paste', function(evt){enable_copy_with_right_click(evt)}, true);
	
	// alert("Test 01");
	
	/////////////////////////////////////////////////////////////////////////////////////////////////////
	
	// Adds CSS rules to undo user-select:none
	
	allowTextSelection();
	
	/////////////////////////////////////////////////////////////////////////////////////////////////////
	
	// Modify a property of External CSS file
	
	var head_tag = content.document.getElementsByTagName("head")[0];
	var links = head_tag.getElementsByTagName("link");

	var arr_css_links = [];

	for(var i=0; i < links.length; i++) {
		var rel = "";
		
		try{
			rel = links[i].getAttribute("rel");
			
		} catch(err){
			// alert(err.message);
		}
		
		if(rel == "stylesheet"){
			var href = links[i].getAttribute("href");
			
			arr_css_links.push(href);
		}
	}

	for(var i=0; i < arr_css_links.length; i++) {
		var str_URL = arr_css_links[i];
		
		// getStyleSheet('https://www.devicespecifications.com/css/style.css?69f56c4dae64ea5633be0eb803b690b3', 'body').style.MozUserSelect = "text";
		
		var object_CSSStyleRule = getStyleSheet(str_URL, 'body');
		
		if(object_CSSStyleRule){
			object_CSSStyleRule.style.MozUserSelect = "text";
		}
	}
	
	/////////////////////////////////////////////////////////////////////////////////////////////////////
	
	prompts.alert(null, "Text Selection", "Text selection (on current page) has been enabled.");
}

window.addEventListener("unload", function (e) {
    window.removeEventListener("unload", arguments.callee, false);
	
    window.removeEventListener('contextmenu', function(evt){enable_copy_with_right_click(evt)}, true);
	window.removeEventListener('copy', function(evt){enable_copy_with_right_click(evt)}, true);
	window.removeEventListener('cut', function(evt){enable_copy_with_right_click(evt)}, true);
	window.removeEventListener('paste', function(evt){enable_copy_with_right_click(evt)}, true);
}, false);


/////////////////////////////////////////////////////  Initialization Code  /////////////////////////////////////////////////////

this.image = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACJ0lEQVR4XoVSzWoTURg9c+dOfpqkWtrQlKJgJkqLJJWCJdlI8Q18AkHwAXwAX6D1CVzUheDSfXfdBBcupNCCbUHcuGsJZiaZJHNzx3MvF2pSpQcOl7nz3e/nnM/rds97S0tlmWUaSmlonUEIH6enP8rHx99fBYH8ACJNFXZ3n8Lg6OgreA8DWSzK8sZGTcIhTYE4HiOX80EcnJycrwgh9rMsw78gMAffBx/ncHHxC5eXPRQK+T2lpm+l9CGEd3sCjzHTqUKr1cDOzmNsbtZ55z3odJ6gUimDndyewGcb/f4QSTLB4mIJnU7rWbV69z0TfwTwmUlea61hIDGHwQDo9WLqEGN7u86qORAh78MoGlCjKWNGL6jNHQr7bqaD0QgYDkfGBdtFPn+dv1QyLFo3oiiiNoV9OrYn4GBGm0xSSCn4U5q5MS+8lB4FDrC2VkWjcR8LC4U3LoF5bOb3SfwXdIFdBVhdXcb6+goTBpD0eKaCEJIuAOZ+DhxvQm2GdtmKxbztUkRRwplSXF1Fjn3yNztSNsCBMZrijTmWZ7QgSywIyMPDL5/ImXJJMk6azYfP2+166MSFUinnl6Yz0nMdetbGl7iGrVyrLRseaI2QcRxJ0xXBJJk9SaPXzUWiRVbhdrtpbOLDzIoLeG7Nbyos3WmrhOE9bG09MutKpvZhEMBqoXXAU5PKbayw9/LvFeaGodv95vYiG5+d/QQRu28Wgfs3tfFxnKg/4LbvPgtrmGgAAAAASUVORK5CYII=";

Screenshots:
01.png
02.png
03.png
04.png
05.png
06.png
07.png
08.png

Custom Buttons Enhanced 0.0.6

https://forum.palemoon.org/viewtopic.php?f=71&t=32626
You do not have the required permissions to view the files attached to this post.

User avatar
jars_
Lunatic
Lunatic
Posts: 427
Joined: 2016-12-27, 00:12

Re: website will not allow text selection

Post by jars_ » 2025-11-05, 16:24

Another option to deal with such 1d10ts - small CB that stops JS and enable selection:
(see tellu-white ↑post for details) Don’t forget to click again to run the scripts again after copying the one you need.

Code: Select all

/*Init*/
this.onclick = clickFunc;

 function clickFunc(e) { 
     if (e.button) return;
   const sss = Cc["@mozilla.org/content/style-sheet-service;1"].getService(Ci.nsIStyleSheetService),
        styl = makeURI("data:text/css," + encodeURIComponent( "*{ user-select: text !important }" ));
      if ( gBrowser.docShell.allowJavascript ) {
            gBrowser.docShell.allowJavascript = false;
            sss.loadAndRegisterSheet(styl, sss.AGENT_SHEET);
            self.style.filter = 'hue-rotate(180deg)'; 
        } else {
             gBrowser.docShell.allowJavascript = true;
             sss.unregisterSheet(styl, sss.AGENT_SHEET);                   
             self.style.filter = 'none';
             }
  };
  

User avatar
therube
Board Warrior
Board Warrior
Posts: 1749
Joined: 2018-06-08, 17:02

Re: website will not allow text selection

Post by therube » 2025-11-05, 17:35

View | Use Style -> None
(Now, with that, you've lost "style", but at least you can select.)

Likewise, zap style sheets (bookmarklet) will do the same.

Enobarbous
Moon lover
Moon lover
Posts: 93
Joined: 2022-12-06, 17:44

Re: website will not allow text selection

Post by Enobarbous » 2025-11-05, 18:01

If you only need to selection, without the context menu, you can use the style:

Code: Select all

@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document domain("canonlawmadeeasy.com") {
  * {
    -moz-user-select: inherit !important;
    -webkit-user-select: inherit !important;
    user-select: inherit !important;
  }
}
I am sorry for the use of auto-translator to post