Created
November 11, 2020 10:41
-
-
Save sertdfyguhi/2a7802681c4f0aa8bbdf5ee9082e53b7 to your computer and use it in GitHub Desktop.
Scriptable widget that gets images from r/japanpics
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
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