-
-
Save matthewberryman/ec49ec938d72cf8a4133da946881f17f to your computer and use it in GitHub Desktop.
A script for Scriptable (https://apps.apple.com/us/app/scriptable/id1405459188) that creates a Midsummer Murders Bot (https://twitter.com/midsomerplots) iOS 14 Widget.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function loadItems() { | |
let url = "https://midsomerplots.acrossthecloud.net/plot?characterLimit=200"; | |
let req = new Request(url); | |
let json; | |
try { | |
json = await req.loadJSON(); | |
} catch (e) { | |
throw e; | |
} | |
return json; | |
} | |
function createWidget(json) { | |
let w = new ListWidget(); | |
w.backgroundColor = new Color("#000099"); | |
w.url = "https://midsomerplots.net/#" + json.seed; | |
let plotTxt = w.addText(json.plot); | |
plotTxt.centerAlignText(); | |
plotTxt.font = Font.callout(); | |
plotTxt.textColor = Color.white(); | |
return w; | |
} | |
try { | |
let json = await loadItems(); | |
if (config.runsInWidget) { | |
let widget = createWidget(json); | |
Script.setWidget(widget); | |
Script.complete(); | |
} else if (config.runsWithSiri) { | |
Speech.speak(json.plot); | |
Script.complete(); | |
} else { | |
let widget = createWidget(json); | |
widget.presentMedium(); | |
Speech.speak(json.plot); | |
} | |
} catch (e) { | |
console.error(e); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment