Created
August 24, 2022 02:14
-
-
Save 10c8/e8b50bd8f52ee5f7681cddc4ab38c4f8 to your computer and use it in GitHub Desktop.
Today's xkcd Comic
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 API_URL = 'https://xkcd.com/info.0.json' | |
const SITE_URL = 'https://xkcd.com' | |
const IMG_SIZE = 158 | |
const data = await (new Request(API_URL)).loadJSON() | |
const img = await (new Request(data.img)).loadImage() | |
const widget = new ListWidget() | |
const wImg = widget.addImage(img) | |
wImg.imageSize = new Size(IMG_SIZE, IMG_SIZE) | |
wImg.applyFillingContentMode() | |
wImg.url = SITE_URL | |
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