Years ago, I made a FireFox addon for myself to do exactly this but everywhere on the internet. You specify a regular express to match attribute values and/or text, and the CSS to apply to the elements containing the matches. You can specify any CSS you want but if it's something like visibility: hidden or display: none it has this effect (and is the only thing I've actually used it for). It even worked on FireFox for Android when that supported proper addons.
It's really nice to never see a link to Facebook, Twitter, etc anywhere on the internet. It's almost like they don't exist. It causes a few oddities here and there (The text matching is problematic but it's optional, the attribute value matching works really well), but I've never missed anything important. I feel like if everyone had this power everywhere, it would serve as incentive for sites to not suck.
It took some fun javascript APIs I've never had to use before (like MutationObserver and TreeWalker) to get it to work right and efficiently, especially on sites that load content via JS (like Google).
It's really nice to never see a link to Facebook, Twitter, etc anywhere on the internet. It's almost like they don't exist. It causes a few oddities here and there (The text matching is problematic but it's optional, the attribute value matching works really well), but I've never missed anything important. I feel like if everyone had this power everywhere, it would serve as incentive for sites to not suck.
It took some fun javascript APIs I've never had to use before (like MutationObserver and TreeWalker) to get it to work right and efficiently, especially on sites that load content via JS (like Google).
Source: https://github.com/7w0/ssure (the interesting bits are in content.js)
Addon: https://addons.mozilla.org/en-US/firefox/addon/ssure/