Your code is based on CSS filters. Dark Reader provides this mode too, but also allows users to fix and share wrongly inverted parts https://github.com/darkreader/darkreader/blob/master/src/con...
Dynamic mode is slower at start, but has no impact on performance after all the stylesheets were analyzed.