-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
54 lines (38 loc) · 1.33 KB
/
script.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
/*
* More user-friendly rewrite of CRX-R using the Fetch API
* to download off of clients2.
*
* I drank the Kool-Aid. Oh yeahhhhh!
*/
"use strict";
const linksDiv = document.getElementById("links");
const textarea = document.getElementById("box");
const submitButton = document.getElementById("submit");
// Set default extensions list
textarea.value =
`# Here's a good list for most of our class.
cjpalhdlnbpafiamejdnhcphjbkeiagm # uBlock Origin
nngceckbapebfimnlniiiahkandclblb # BitWarden
`
// Run the actual code when user clicks submit
submitButton.addEventListener("click", main);
function main() {
const ids = textarea.value.split("\n");
ids.forEach((line) => {
// Strip out comments
const id = (line.split("#")[0]).trim();
if (id.length <= 0) return;
const a = document.createElement("a");
a.href = formatDownloadUrl(id);
a.download = id+".zip";
a.classList.add("downloadLink");
a.innerText = id;
a.onclick = (() => a.remove());
linksDiv.appendChild(a);
});
textarea.value = "";
linksDiv.scrollIntoView();
}
function formatDownloadUrl(id) {
return `https://clients2.google.com/service/update2/crx?response=redirect&os=linux&arch=x64&os_arch=x86_64&nacl_arch=x86-64&prod=chromium&prodchannel=unknown&prodversion=91.0.4442.4&lang=en-US&acceptformat=crx2,crx3&x=id%3D${id}%26installsource%3Dondemand%26uc`;
}