Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Readme

Sends me an email if Sweden's requirements for EU Blue Card changes. Checks once an hour.

Runs every 1 hrs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { blob } from "https://esm.town/v/std/blob?v=12";
import { email } from "https://esm.town/v/std/email?v=12";
const site =
"https://www.migrationsverket.se/English/Private-individuals/Working-in-Sweden/Employed/Special-rules-for-certain-occupations-and-citizens-of-certain-countries/EU-Blue-Card.html";
const dateChangedKey = "work-permit-change-date";
export default async function(interval: Interval) {
const page = await fetch(site).then(res => res.text());
const date = page.match(/Last updated: <time datetime="([^"]+)">/)?.[1].toString();
const lastChange = await blob.get(dateChangedKey).then(res => res?.text()).catch(() => "");
if (!date) {
throw new Error("Couldn't find date");
}
if (!lastChange || date === lastChange) {
return;
}
await blob.set(dateChangedKey, date);
await email({
subject: `EU Blue Card requirements page changed at ${new Date(date).toDateString()}`,
text: `Go check ${site}`,
});
}
April 13, 2024