Last active
March 3, 2026 12:51
-
-
Save corwin-of-amber/898c86a34b4db85127fb8cd9d9028723 to your computer and use it in GitHub Desktop.
oref.org.il alters
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
| #!/usr/bin/env zx | |
| const LOC = "תל אביב - עבר הירקון"; | |
| function head(s, n=10) { | |
| if (typeof s === 'object') s = JSON.stringify(s, null, 2); | |
| return s.split('\n').slice(0, n).join('\n'); | |
| } | |
| let a = await (await fetch('https://www.oref.org.il/warningMessages/alert/Alerts.json')).json().catch(() => ({})); | |
| let b = await (await fetch('https://www.oref.org.il/warningMessages/alert/History/AlertsHistory.json')).json().catch(() => ([])); | |
| let c = await (await fetch(`https://alerts-history.oref.org.il/Shared/Ajax/GetAlarmsHistory.aspx?lang=he&mode=1&city_0=${LOC}`)).json().catch(() => ([])); | |
| let old = await fs.readFile('/tmp/a.json', 'utf-8') | |
| .then(JSON.parse).catch(() => ({})); | |
| console.log(head(a)) | |
| console.log(head(b.filter(r => r.data == LOC), 15)) | |
| console.log(head(c.filter(r => r.data == LOC), 20)) | |
| if (a?.id && old?.id !== a.id && a.data.some(r => r == LOC)) | |
| $`alerter --message ${`${a.data}`} --title ${a.title} --timeout 3` | |
| fs.writeFile('/tmp/a.json', JSON.stringify(a)) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Mac users: use Homebrew.