Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: red; icon-glyph: magic;
// for https://talk.automators.fm/t/bug-device-isusingdarkappearance-in-widget-always-returns-true/8721/5
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
}
var widget = new ListWidget()
widget.setPadding(0,0,0,0)
widget.addSpacer()
var t1 = widget.addText('Device.isUsingDarkAppearance')
t1.centerAlignText()
t1.font = Font.regularSystemFont(10)
var t2 = widget.addText(`${Device.isUsingDarkAppearance()}`)
t2.centerAlignText()
t2.font = Font.regularSystemFont(10)
widget.addSpacer(10)
var t3 = widget.addText('await isUsingDarkAppearance')
t3.centerAlignText()
t3.font = Font.regularSystemFont(10)
var t4 = widget.addText(`${await isUsingDarkAppearance()}`)
t4.centerAlignText()
t4.font = Font.regularSystemFont(10)
widget.addSpacer()
widget.presentSmall()
Script.setWidget(widget)
widget.presentSmall()
Script.complete()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment