mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-14 17:13:03 -04:00
Vencord Standalone without git/node (#148)
This commit is contained in:
parent
ffbb52512c
commit
5fac8be0ae
30 changed files with 373 additions and 129 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue