Skip to content

Instantly share code, notes, and snippets.

@sertdfyguhi
Created November 11, 2020 10:41
Show Gist options
  • Save sertdfyguhi/2a7802681c4f0aa8bbdf5ee9082e53b7 to your computer and use it in GitHub Desktop.
Save sertdfyguhi/2a7802681c4f0aa8bbdf5ee9082e53b7 to your computer and use it in GitHub Desktop.
Scriptable widget that gets images from r/japanpics
let list = new ListWidget()
let req = new Request("https://reddit.com/r/japanpics/random.json")
let res = await req.loadJSON()
list.backgroundImage = await getImage()
list.url = res[0].data.children[0].data.url_overridden_by_dest
list.presentMedium()
Script.setWidget(list)
Script.complete()
async function getImage() {
let imgReq = new Request(res[0].data.children[0].data.url_overridden_by_dest)
let img = await imgReq.loadImage()
return img
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment