Also struggled with that issue. What I found is that there is a style applied onto the iframe: "filter: var(--invert-filter);" which applies this CSS: filter: invert(1) saturate(0.5).
I couldn't find any elements within the iframe that I can use to detect if dark mode is on or not. But since most people use system settings detection to use dark mode or light mode, the simplest way I found is this - in order to invert colors back to normal we apply filter: invert(1) again, and add saturate(2) to up the saturation back from saturate(0.5). Add this script anywhere within the HTML <head> or <body> it will invert the colors back to normal if the user's system prefers dark mode.
<script>
if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
document.firstChild.style.setProperty("filter", "invert(1) saturate(2)", "important")
}
</script>
Alternatively, there is dark/light mode switch in the top right corner of the HTML rendering (sun/moon icon), that will get you back to regular view without inverting, but the user has to toggle it manually.
