I tried to paste the code and it doesn't translate well at all.
Basically I made a "dim" function and set it to run every second. It attaches the brightness filter (if it hasn't already been attached (don't forget to check this, otherwise it will add to the style tag every second)) and makes it !important.
It attaches the filter to every img element, and every div that has "background-image" in the style string.
I'm sure there are other gotchas, but this has worked well so far.
filter: brightness(50%) !important
When I used Chrome, I just added the "image-dimmer" extension. It does exactly this.