Sounds like you want this:
It will also add dom wrappers, but removes them when done.
The only other way I can think of doing what you want would be:
mix-blend-mode: darken
mix-blend-mode: lighten. Also, good luck determining the background color and text as those can be stored on basically anywhere in the DOM.You're better off just using that library, or finding a different way approach or define your problem space.