Skip to content

Instantly share code, notes, and snippets.

@varenc
Created January 19, 2024 02:04
Show Gist options
  • Save varenc/1bd977a3edbe11b160598d5c0c6ae15e to your computer and use it in GitHub Desktop.
Save varenc/1bd977a3edbe11b160598d5c0c6ae15e to your computer and use it in GitHub Desktop.
Force iccsafe.org code text to be selectable and copyable
function __unblockEvents(){for(var i=0;i<arguments.length;i++){document.addEventListener(arguments[i],function(e){e.stopPropagation();console.log("event received and unblocked:",e);},true);}};
__unblockEvents('keydown','keyup','keypress','copy','contextmenu','beforeprint','afterprint');
document.head.appendChild(Object.assign(document.createElement("style"), {textContent: "* { user-select: initial !important; }"}));
// TODO: disabling 'beforeprint' doesnt seem to work. Fix that so its printable. Use Chrome Dev tools to remove that event handler manually in the mean time.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment