Last active
February 22, 2022 21:20
-
-
Save Erquint/fbea345ae863fea3735fc35f25c753f7 to your computer and use it in GitHub Desktop.
CSS property `user-select` is used to disable or alter selectability of rendered HTML elements. This userscript unsets all such style properties on a page. Install using the following link: https://gist.github.com/Erquint/5ed7be3f1c62c606d7c514deec4d091d/raw/user-select_unsetter.user.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name user-select unsetter | |
// @description Waits for page to fully load once and selectively unsets the `user-select` property of all elements. | |
// @version 1.0.0 | |
// @namespace gness.na@gmail.com | |
// @author https://gist.github.com/Erquint | |
// @homepageURL https://gist.github.com/Erquint/fbea345ae863fea3735fc35f25c753f7 | |
// @updateURL https://gist.githubusercontent.com/Erquint/fbea345ae863fea3735fc35f25c753f7/raw/user-select_unsetter.user.js | |
// @downloadURL https://gist.githubusercontent.com/Erquint/fbea345ae863fea3735fc35f25c753f7/raw/user-select_unsetter.user.js | |
// @match *://*/* | |
// @run-at document-idle | |
// ==/UserScript== | |
properties = [ | |
'user-select', | |
'-moz-user-select', | |
'-webkit-user-select', | |
'-ms-user-select' | |
] | |
styles = [...window.document.body.querySelectorAll('*')].map(element => element.style); | |
[...window.document.styleSheets].forEach(sheet => { | |
try{ | |
[...sheet.cssRules].forEach(rule => { | |
styles.push(rule.style); | |
}); | |
}catch(e){}; | |
}); | |
styles = styles.filter(e => e); | |
styles.forEach(style => { | |
properties.forEach(property => { | |
if(style.getPropertyValue(property)){style.removeProperty(property)}; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment