Last active
April 18, 2026 16:07
-
-
Save mattapperson/114e5267d5bc736fbe616b6205f3df92 to your computer and use it in GitHub Desktop.
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 dailyText = await loadText() | |
| if (config.runsInWidget) { | |
| let widget = createWidget(dailyText) | |
| Script.setWidget(widget) | |
| Script.complete() | |
| } else { | |
| Safari.open(dailyText.url.replace('/wol/','jwpub://' )) | |
| } | |
| function createWidget(dailyText) { | |
| const scripture = extractScripture(dailyText).replace(/<[^>]*>?/gm, ''); | |
| const text = extractText(dailyText).replace(/<[^>]*>?/gm, '') | |
| let w = new ListWidget() | |
| w.backgroundColor = new Color("#4a6da7") | |
| w.centerAlignContent() | |
| let titleTxt = w.addText(scripture) | |
| titleTxt.applyHeadlineTextStyling() | |
| titleTxt.textSize = 13 | |
| titleTxt.textColor = Color.white() | |
| let article = w.addText(text) | |
| article.applyBodyTextStyling() | |
| article.textColor = Color.white() | |
| article.textOpacity = 0.8 | |
| article.textSize = 12 | |
| return w | |
| } | |
| async function loadText() { | |
| const date = new Date() | |
| let url = `https://wol.jw.org/wol/dt/r1/lp-e/${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}` | |
| let req = new Request(url) | |
| let json = await req.loadJSON() | |
| return json.items[0] | |
| } | |
| function extractScripture(item) { | |
| let regex = /<em>(.*)<\/em>/ | |
| let html = item.content | |
| let matches = html.match(regex) | |
| if (matches && matches.length >= 2) { | |
| return matches[1] | |
| } else { | |
| return null | |
| } | |
| } | |
| function extractText(item) { | |
| let html = item.content.split("<p")[2].split(/>(.+)/)[1] | |
| if (html) { | |
| return html | |
| } else { | |
| return null | |
| } | |
| } |
Hey really cool widget. One thing i don't get it. Can someone explain me where it says it runs daily?
Hi guys, sorry I’m a bit late but I love the widget. I expanded on this on this GitHub page, please tell me what y’all think of it: https://thijnperd.github.io/Dagtekst-Widget/
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just an update to:
<em>tags.