-
Notifications
You must be signed in to change notification settings - Fork 0
/
a.js
60 lines (42 loc) · 1.42 KB
/
a.js
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
50
51
52
53
54
55
56
57
58
59
60
const BASE = `https://www.nvidia.com`;
async function get_driver(beta) {
const isLinux = Deno.build.os === 'linux';
const params = new URLSearchParams("psid=101&pfid=845&rpf=1&lid=1&ctk=0&dtid=17");
params.set("osid", isLinux ? 12 : 135);
params.set("dtcid", isLinux ? 0 : 1);
if (!isLinux && beta) {
params.set('dtid', 18);
} else if (beta || !isLinux) {
params.set('dtid', 1);
}
const URI = new URL(`${BASE}/Download/processDriver.aspx?` + params.toString());
const r = await fetch(URI);
const driver_url = await r.text();
const r_D = await fetch(driver_url);
const rBody = await r_D.text();
const DL = rBody.match(/href="(.+)" id="lnkDwnldBtn"/);
if (!DL) {
throw new Error("fail to parse")
}
return await get_link(BASE + DL[1]);
}
async function get_unstable() {
const R = await fetch("https://forums.developer.nvidia.com/t/current-graphics-driver-releases/28500");
const txt = await R.text();
const result = txt.match(/Current beta release: <a href=".+" data-bbcode="true">.+<\/a> \(<a href="(.+)" data-bbcode="true">x86_64/);
if (result) {
return result[1]
}
}
async function get_link(url) {
const R = await fetch(url);
const txt = await R.text();
const USDL = txt.match(/href="(\/\/us\.down.+)"/);
if (USDL) {
return USDL[1];
}
}
const [stable,beta,unstable] = await Promise.all([get_driver(), get_driver(true), get_unstable()]);
console.log(stable);
console.log(beta);
console.log(unstable);