Created
November 11, 2020 10:42
-
-
Save sertdfyguhi/46951cc72704863d62fa5e88a6c90af2 to your computer and use it in GitHub Desktop.
Scriptable widget that gets images r/earthporn
This file contains hidden or 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/earthporn/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