I had the same issue with my xkcd widget. I made a separate function to solve it. it’s an async
function though but not too much of an issue.
async function isUsingDarkAppearance() {
const wv = new WebView()
let js ="(window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches)"
let r = await wv.evaluateJavaScript(js)
return r
}