Last active
March 10, 2024 13:28
-
-
Save alldritt/1a242ba62f96cb486dbedd76b039dd14 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"; | |
let req = new Request(url); | |
let json = await req.loadJSON(); | |
return json; | |
} | |
function createWidget(plot) { | |
let w = new ListWidget() | |
w.backgroundColor = new Color("#b00a0f") | |
let plotTxt = w.addText(plot) | |
plotTxt.centerAlignText() | |
plotTxt.font = Font.callout() | |
plotTxt.textColor = Color.white() | |
return w | |
} | |
let json = await loadItems(); | |
console.log(json["plot"]); | |
if (config.runsInWidget) { | |
let widget = createWidget(json["plot"]); | |
Script.setWidget(widget); | |
Script.complete(); | |
} else { | |
let widget = createWidget(json["plot"]); | |
widget.presentMedium(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So I shoved a
ShareSheet.present(["https://midsomerplots.net/#"+json["seed"]])
into the widget, but there are two issues:a) It worked when run from Scriptable, however how to trigger it only on tap?
b) In widget form, it throws an error saying the ShareSheets aren't supported for widgets.