Skip to content

Instantly share code, notes, and snippets.

@10c8
Created August 24, 2022 02:14
Show Gist options
  • Save 10c8/e8b50bd8f52ee5f7681cddc4ab38c4f8 to your computer and use it in GitHub Desktop.
Save 10c8/e8b50bd8f52ee5f7681cddc4ab38c4f8 to your computer and use it in GitHub Desktop.
Today's xkcd Comic
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