-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHELPERS.js
More file actions
49 lines (46 loc) · 1.26 KB
/
HELPERS.js
File metadata and controls
49 lines (46 loc) · 1.26 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// DO NOT EXECUTE (for reference only)
// Grab most-likely inputs
const EXAMPLES = /<pre><code>(.*?)<\/code><\/pre>/gs;
(async () => {
const out = [];
for (let i = 1; i <= 25; i++) {
const resp = await fetch(`https://adventofcode.com/2024/day/${i}`);
const text = await resp.text();
out.push(
[...text.matchAll(EXAMPLES)].map((i) =>
i[1]
.replaceAll(/<em>(.*?)<\/em>/gs, "$1")
.replaceAll("<", "<")
.replaceAll(">", ">")
.replaceAll("&", "&"),
),
);
}
console.log(out);
})();
// Grab inputs for the current page
const EXAMPLES2 = /<pre><code>(.*?)<\/code><\/pre>/gs;
(async () => {
const resp = await fetch(location.href);
const text = await resp.text();
console.log(
[...text.matchAll(EXAMPLES2)].map((i) =>
i[1]
.replaceAll(/<em>(.*?)<\/em>/gs, "$1")
.replaceAll("<", "<")
.replaceAll(">", ">")
.replaceAll("&", "&"),
),
);
})();
// Grab problem titles
const DAY = /--- Day \d+: (.*)? ---/;
(async () => {
const out = [];
for (let i = 1; i <= 25; i++) {
const resp = await fetch(`https://adventofcode.com/2024/day/${i}`);
const text = await resp.text();
out.push(text.match(DAY)[1]);
}
console.log(out);
})();