Chrome extension which could inject dynamically-updated CSS?

42 Views Asked by At

I was considering creating an extension to hide specific Mastodon posts. Let's say I’m afraid of snakes and want to make sure I can hide any post with a pic of a snake in it (I'm already filtering by the word).

  • Each post has a data-id by which it can be styled.
  • For a one-off, that's all I need, I can hide it with Javascript
  • But to make the change persistent, I would need to have a CSS injected with display:none for all the posts I’ve hidden (or a <style> element in the DOM?)
  • So I would need to have an extension which could add a line to a CSS file, or which would pull the CSS dynamically from a database, or write out a new local file from a database when a new post was hidden

Which of those things is even possible? Can an extension rewrite its own files?

0

There are 0 best solutions below