0

I want to write a Greasemonkey script to delete specific HTML elements from the view of a web app I use frequently. These elements are identified by class names like "sidebar-2K8pFh". I suspect these are hashes that will change every time the web app is updated. If I use document.getElementsByClassName(), such a change will break my script, so instead, I want to find and delete every element on the page belonging to a class that would match the regular expression /^sidebar-.*$/. (Only one such element exists on the page; I'm not sure why it's a class instead of an ID.)

How do I search the DOM for elements with classes with names that match a pattern rather than an exact string? It doesn't have to be regex; I just need a way to filter elements based on their class names without treating those class names as atomic units.

Foobie Bletch
  • 214
  • 1
  • 9

0 Answers0