Skip to content

Instantly share code, notes, and snippets.

@SushiWaUmai
Last active August 5, 2022 16:38
Show Gist options
  • Save SushiWaUmai/e98c22bbcdfeb8b841ff9b93f99df711 to your computer and use it in GitHub Desktop.
Save SushiWaUmai/e98c22bbcdfeb8b841ff9b93f99df711 to your computer and use it in GitHub Desktop.
iOS Widget which shows AI-generated waifus generated by thiswaifudoesnotexist.net
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