Last active
August 5, 2022 16:38
-
-
Save SushiWaUmai/e98c22bbcdfeb8b841ff9b93f99df711 to your computer and use it in GitHub Desktop.
iOS Widget which shows AI-generated waifus generated by thiswaifudoesnotexist.net
This file contains 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
const createWidget = (img, url) => { | |
let w = new ListWidget(); | |
w.backgroundImage = img; | |
w.url = url; | |
return w; | |
}; | |
const main = async () => { | |
const type = args.widgetParameter ?? "sfw/waifu"; | |
const url = `https://api.waifu.pics/${type}`; | |
const req = new Request(url); | |
const data = await req.loadJSON(); | |
const imgurl = data.url; | |
const imgreq = new Request(imgurl); | |
const img = await imgreq.loadImage(); | |
let widget = createWidget(img, url); | |
if (config.runsInWidget) { | |
Script.setWidget(widget); | |
Script.complete(); | |
} else { | |
widget.presentLarge(); | |
} | |
}; | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment