Skip to content

Instantly share code, notes, and snippets.

Avatar

Alexander S. xsynaptic

View GitHub Profile
@xsynaptic
xsynaptic / restore-selection.js
Created Nov 18, 2019
Bookmarklet: Restore text selection and context menu
View restore-selection.js
javascript:function restoreSelection(){console.log('Attempting to restore text selection!');var style=document.createElement("style");style.type="text/css",style.innerHTML="*, p, div { -moz-user-select: text !important;-webkit-user-select:text !important;user-select: text !important; }",document.head.appendChild(style),document.querySelectorAll("*").forEach(el=>{el.onselectstart=el.ondragstart=el.ondrag=el.oncontextmenu=el.onmousedown=el.onmouseup=function(){return!0}})}restoreSelection();