aboutsummaryrefslogtreecommitdiff
path: root/src/ipcMain/extensions.ts
diff options
context:
space:
mode:
authorVen <vendicated@riseup.net>2022-10-23 23:23:52 +0200
committerGitHub <noreply@github.com>2022-10-23 23:23:52 +0200
commit5fac8be0ae68cbbdf3514973cbf925a31a765ef5 (patch)
tree8c184e0a2a9c8f4480e4c3880a58833e089a3da6 /src/ipcMain/extensions.ts
parentffbb52512cd61764cfe04c1cf2707eb63d5e57bf (diff)
downloadVencord-5fac8be0ae68cbbdf3514973cbf925a31a765ef5.tar.gz
Vencord-5fac8be0ae68cbbdf3514973cbf925a31a765ef5.tar.bz2
Vencord-5fac8be0ae68cbbdf3514973cbf925a31a765ef5.zip
Vencord Standalone without git/node (#148)
Diffstat (limited to 'src/ipcMain/extensions.ts')
-rw-r--r--src/ipcMain/extensions.ts24
1 files changed, 3 insertions, 21 deletions
diff --git a/src/ipcMain/extensions.ts b/src/ipcMain/extensions.ts
index d676f22..0e26ff1 100644
--- a/src/ipcMain/extensions.ts
+++ b/src/ipcMain/extensions.ts
@@ -19,33 +19,15 @@
import { session } from "electron";
import { unzip } from "fflate";
import { constants as fsConstants } from "fs";
-import { access,mkdir, rm, writeFile } from "fs/promises";
-import https from "https";
+import { access, mkdir, rm, writeFile } from "fs/promises";
import { join } from "path";
import { DATA_DIR } from "./constants";
import { crxToZip } from "./crxToZip";
+import { get } from "./simpleGet";
const extensionCacheDir = join(DATA_DIR, "ExtensionCache");
-function download(url: string) {
- return new Promise<Buffer>((resolve, reject) => {
- https.get(url, res => {
- const { statusCode, statusMessage, headers } = res;
- if (statusCode! >= 400)
- return void reject(`${statusCode}: ${statusMessage} - ${url}`);
- if (statusCode! >= 300)
- return void resolve(download(headers.location!));
-
- const chunks = [] as Buffer[];
- res.on("error", reject);
-
- res.on("data", chunk => chunks.push(chunk));
- res.once("end", () => resolve(Buffer.concat(chunks)));
- });
- });
-}
-
async function extract(data: Buffer, outDir: string) {
await mkdir(outDir, { recursive: true });
return new Promise<void>((resolve, reject) => {
@@ -86,7 +68,7 @@ export async function installExt(id: string) {
await access(extDir, fsConstants.F_OK);
} catch (err) {
const url = `https://clients2.google.com/service/update2/crx?response=redirect&acceptformat=crx2,crx3&x=id%3D${id}%26uc&prodversion=32`;
- const buf = await download(url);
+ const buf = await get(url);
await extract(crxToZip(buf), extDir);
}