I see what’s happening! The issue is that your script is trying to modify styles using element.style, but that only works for inline styles—and most of the time, user-select: none is applied through CSS stylesheets, not inline styles. That’s why your changes aren’t sticking.
Why isn’t it working?
element.style.userSelect
only affects inline styles. If user-select: none
comes from an external CSS file, element.style.userSelect
won’t
see it at all.element.style.cssText.replace(...)
won’t help, because it
doesn’t affect styles defined in a stylesheet.user-select: none
in DevTools, but that doesn’t mean it’s an
inline style.How to Fix
Instead of modifying styles element-by-element, you should inject a new global CSS rule that overrides the existing one.
const style = document.createElement('style');
style.innerHTML = `* { user-select: contain !important; }`;
document.head.appendChild(style);