I just developed and implemented a dark mode for my website that employs bespoke dark colours to complement the light (default) colour scheme, and I also recently discovered that Chrome 78 includes an optional feature called #enable-force-dark. When enabled (the user must do so), Chrome will attempt to convert websites to a dark theme. It does so independently of the OS's preference, which means that a user can set light mode system-wide yet Chrome would still convert with this flag enabled.
As mentioned in previous forums, I'm using the following code to determine whether or not a user's device likes dark mode. It's worth noting that I'm detecting it using javascript since there's a button that toggles it back and forth, and it eventually ended up being a bug.
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
// my dark mode code goes here
}
This if statement is included within a jQuery $(window).load method and works flawlessly.
What I need is the ability to detect Chrome's new #enable-force-dark setting, reverse the modifications Chrome performs, and enable my own instead, because the Chrome conversion is incomplete and messes up my own styles. I'm conscious that this functionality isn't generally used, but I'd like to be prepared for the future.
Is this in any way possible? I don't need to ask the user to disable that flag, although if necessary I will. Thank you!