79419892

Date: 2025-02-07 02:59:09
Score: 2.5
Natty:
Report link

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?

  1. 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.
  2. Even element.style.cssText.replace(...) won’t help, because it doesn’t affect styles defined in a stylesheet.
  3. DevTools (F12) shows "computed styles," not inline styles. You might see 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);
Reasons:
  • RegEx Blacklisted phrase (2): working?
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: Kai Brooks