From 876e622f4f61a4aa229ad69782d374335c3d8d6b Mon Sep 17 00:00:00 2001 From: Vendicated Date: Mon, 29 Aug 2022 18:11:44 +0200 Subject: [PATCH] Progress --- build.mjs | 82 +++++++++++++++++++++++++-- package.json | 4 ++ pnpm-lock.yaml | 124 +++++++++++++++++++++++++++++++++++++++++ src/Vencord.ts | 4 +- src/VencordNative.ts | 11 ++++ src/globals.d.ts | 13 +++-- src/ipcMain.ts | 25 +++++++++ src/patcher.ts | 25 ++++----- src/plugins.d.ts | 4 ++ src/plugins/bar.ts | 3 + src/plugins/foo.ts | 3 + src/plugins/index.ts | 3 + src/preload.ts | 8 +-- src/utils/constants.ts | 3 - src/utils/ipcEvents.ts | 3 + src/utils/quickCss.ts | 6 ++ tsconfig.json | 2 +- 17 files changed, 289 insertions(+), 34 deletions(-) create mode 100644 src/VencordNative.ts create mode 100644 src/ipcMain.ts create mode 100644 src/plugins.d.ts create mode 100644 src/plugins/bar.ts create mode 100644 src/plugins/foo.ts create mode 100644 src/plugins/index.ts create mode 100644 src/utils/ipcEvents.ts create mode 100644 src/utils/quickCss.ts diff --git a/build.mjs b/build.mjs index f74cf693..237b2198 100755 --- a/build.mjs +++ b/build.mjs @@ -1,21 +1,80 @@ #!/usr/bin/node import esbuild from "esbuild"; +import { readdirSync } from "fs"; +import { performance } from "perf_hooks"; +/** + * @type {esbuild.WatchMode} + */ +const watch = { + onRebuild: (err) => { + if (err) console.error("Build Error", err.message); + else console.log("Rebuilt!"); + } +}; + +// https://github.com/evanw/esbuild/issues/619#issuecomment-751995294 +const makeAllPackagesExternalPlugin = { + name: 'make-all-packages-external', + setup(build) { + let filter = /^[^.\/]|^\.[^.\/]|^\.\.[^\/]/; // Must not start with "/" or "./" or "../" + build.onResolve({ filter }, args => ({ path: args.path, external: true })); + }, +}; + +const globPlugins = { + name: "glob-plugins", + setup: build => { + build.onResolve({ filter: /^plugins$/ }, args => { + return { + namespace: "import-plugins", + path: args.path + }; + }); + + build.onLoad({ filter: /^plugins$/, namespace: "import-plugins" }, () => { + const files = readdirSync("./src/plugins"); + let code = ""; + let arr = "["; + for (let i = 0; i < files.length; i++) { + if (files[i] === "index.ts") { + continue; + } + const mod = `__pluginMod${i}`; + code += `import ${mod} from "./${files[i].replace(".ts", "")}";\n`; + arr += `${mod},`; + } + code += `export default ${arr}]`; + return { + contents: code, + resolveDir: "./src/plugins" + }; + }); + } +}; + +const begin = performance.now(); await Promise.all([ esbuild.build({ entryPoints: ["src/preload.ts"], outfile: "dist/preload.js", format: "cjs", - treeShaking: true, + bundle: true, platform: "node", - target: ["esnext"] + target: ["esnext"], + plugins: [makeAllPackagesExternalPlugin], + watch }), esbuild.build({ entryPoints: ["src/patcher.ts"], outfile: "dist/patcher.js", + bundle: true, format: "cjs", target: ["esnext"], - platform: "node" + external: ["electron"], + platform: "node", + plugins: [makeAllPackagesExternalPlugin], + watch }), esbuild.build({ entryPoints: ["src/Vencord.ts"], @@ -24,8 +83,19 @@ await Promise.all([ bundle: true, target: ["esnext"], footer: { js: "//# sourceURL=VencordRenderer" }, - globalName: "Vencord" + globalName: "Vencord", + external: ["plugins"], + plugins: [ + globPlugins + ], + watch }) -]); +]).then(res => { + const took = performance.now() - begin; + console.log(`Built in ${took.toFixed(2)}ms`); +}).catch(err => { + console.error("Build failed"); + console.error(err.message); +}); -console.log("Built!"); \ No newline at end of file +if (watch) console.log("Watching..."); \ No newline at end of file diff --git a/package.json b/package.json index 50a54e08..6592d00d 100644 --- a/package.json +++ b/package.json @@ -8,5 +8,9 @@ "electron-devtools-installer": "^3.2.0", "jsposed": "^1.0.2", "prettier": "^2.7.1" + }, + "scripts": { + "build": "node build.mjs", + "watch": "node build.mjs --watch" } } \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index edf432de..0bc52ca1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5,6 +5,7 @@ specifiers: electron: ^20.1.0 electron-devtools-installer: ^3.2.0 esbuild: ^0.15.5 + esbuild-plugin-import-glob: ^0.1.1 jsposed: ^1.0.2 prettier: ^2.7.1 @@ -17,6 +18,7 @@ devDependencies: '@types/node': 18.7.13 electron: 20.1.0 esbuild: 0.15.5 + esbuild-plugin-import-glob: 0.1.1 packages: @@ -47,6 +49,27 @@ packages: dev: true optional: true + /@nodelib/fs.scandir/2.1.5: + resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} + engines: {node: '>= 8'} + dependencies: + '@nodelib/fs.stat': 2.0.5 + run-parallel: 1.2.0 + dev: true + + /@nodelib/fs.stat/2.0.5: + resolution: {integrity: sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==} + engines: {node: '>= 8'} + dev: true + + /@nodelib/fs.walk/1.2.8: + resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==} + engines: {node: '>= 8'} + dependencies: + '@nodelib/fs.scandir': 2.1.5 + fastq: 1.13.0 + dev: true + /@sindresorhus/is/0.14.0: resolution: {integrity: sha512-9NET910DNaIPngYnLLPeg+Ogzqsi9uM4mSboU5y6p8S5DzMTVEsJZrawi+BoDNUVBa2DhJqQYUFvMDfgU062LQ==} engines: {node: '>=6'} @@ -91,6 +114,13 @@ packages: concat-map: 0.0.1 dev: false + /braces/3.0.2: + resolution: {integrity: sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==} + engines: {node: '>=8'} + dependencies: + fill-range: 7.0.1 + dev: true + /buffer-crc32/0.2.13: resolution: {integrity: sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==} dev: true @@ -359,6 +389,12 @@ packages: dev: true optional: true + /esbuild-plugin-import-glob/0.1.1: + resolution: {integrity: sha512-yAFH+9AoIcsQkODSx0KUPRv1FeJUN6Tef8vkPQMcuVkc2vXYneYKsHhOiFS/yIsg5bQ70HHtAlXVA1uTjgoJXg==} + dependencies: + fast-glob: 3.2.11 + dev: true + /esbuild-sunos-64/0.15.5: resolution: {integrity: sha512-2sIzhMUfLNoD+rdmV6AacilCHSxZIoGAU2oT7XmJ0lXcZWnCvCtObvO6D4puxX9YRE97GodciRGDLBaiC6x1SA==} engines: {node: '>=12'} @@ -444,12 +480,36 @@ packages: - supports-color dev: true + /fast-glob/3.2.11: + resolution: {integrity: sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew==} + engines: {node: '>=8.6.0'} + dependencies: + '@nodelib/fs.stat': 2.0.5 + '@nodelib/fs.walk': 1.2.8 + glob-parent: 5.1.2 + merge2: 1.4.1 + micromatch: 4.0.5 + dev: true + + /fastq/1.13.0: + resolution: {integrity: sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw==} + dependencies: + reusify: 1.0.4 + dev: true + /fd-slicer/1.1.0: resolution: {integrity: sha512-cE1qsB/VwyQozZ+q1dGxR8LBYNZeofhEdUNGSMbQD3Gw2lAzX9Zb3uIU6Ebc/Fmyjo9AWWfnn0AUCHqtevs/8g==} dependencies: pend: 1.2.0 dev: true + /fill-range/7.0.1: + resolution: {integrity: sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==} + engines: {node: '>=8'} + dependencies: + to-regex-range: 5.0.1 + dev: true + /fs-extra/8.1.0: resolution: {integrity: sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==} engines: {node: '>=6 <7 || >=8'} @@ -491,6 +551,13 @@ packages: pump: 3.0.0 dev: true + /glob-parent/5.1.2: + resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} + engines: {node: '>= 6'} + dependencies: + is-glob: 4.0.3 + dev: true + /glob/7.2.3: resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==} dependencies: @@ -602,6 +669,23 @@ packages: dev: true optional: true + /is-extglob/2.1.1: + resolution: {integrity: sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==} + engines: {node: '>=0.10.0'} + dev: true + + /is-glob/4.0.3: + resolution: {integrity: sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==} + engines: {node: '>=0.10.0'} + dependencies: + is-extglob: 2.1.1 + dev: true + + /is-number/7.0.0: + resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==} + engines: {node: '>=0.12.0'} + dev: true + /isarray/1.0.0: resolution: {integrity: sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==} dev: false @@ -675,6 +759,19 @@ packages: dev: true optional: true + /merge2/1.4.1: + resolution: {integrity: sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==} + engines: {node: '>= 8'} + dev: true + + /micromatch/4.0.5: + resolution: {integrity: sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==} + engines: {node: '>=8.6'} + dependencies: + braces: 3.0.2 + picomatch: 2.3.1 + dev: true + /mimic-response/1.0.1: resolution: {integrity: sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==} engines: {node: '>=4'} @@ -744,6 +841,11 @@ packages: resolution: {integrity: sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==} dev: true + /picomatch/2.3.1: + resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} + engines: {node: '>=8.6'} + dev: true + /pify/3.0.0: resolution: {integrity: sha512-C3FsVNH1udSEX48gGX1xfvwTWfsYWj5U+8/uK15BGzIGrKoUpghX8hWZwa/OFnakBiiVNmBvemTJR5mcy7iPcg==} engines: {node: '>=4'} @@ -782,6 +884,10 @@ packages: once: 1.4.0 dev: true + /queue-microtask/1.2.3: + resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} + dev: true + /readable-stream/2.3.7: resolution: {integrity: sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==} dependencies: @@ -800,6 +906,11 @@ packages: lowercase-keys: 1.0.1 dev: true + /reusify/1.0.4: + resolution: {integrity: sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==} + engines: {iojs: '>=1.0.0', node: '>=0.10.0'} + dev: true + /rimraf/3.0.2: resolution: {integrity: sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==} hasBin: true @@ -820,6 +931,12 @@ packages: dev: true optional: true + /run-parallel/1.2.0: + resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} + dependencies: + queue-microtask: 1.2.3 + dev: true + /safe-buffer/5.1.2: resolution: {integrity: sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==} dev: false @@ -878,6 +995,13 @@ packages: engines: {node: '>=6'} dev: true + /to-regex-range/5.0.1: + resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} + engines: {node: '>=8.0'} + dependencies: + is-number: 7.0.0 + dev: true + /tslib/2.4.0: resolution: {integrity: sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==} dev: false diff --git a/src/Vencord.ts b/src/Vencord.ts index 2a4a60a1..449423cd 100644 --- a/src/Vencord.ts +++ b/src/Vencord.ts @@ -1,3 +1,5 @@ import "./utils/patchWebpack"; +import "./utils/quickCss"; -export const Webpack = {}; \ No newline at end of file +export const Webpack = {}; +import "./plugins"; diff --git a/src/VencordNative.ts b/src/VencordNative.ts new file mode 100644 index 00000000..1798cbf3 --- /dev/null +++ b/src/VencordNative.ts @@ -0,0 +1,11 @@ +import { IPC_QUICK_CSS_UPDATE, IPC_GET_QUICK_CSS } from './utils/ipcEvents'; +import { ipcRenderer } from 'electron'; + +export default { + handleQuickCssUpdate(cb: (s: string) => void) { + ipcRenderer.on(IPC_QUICK_CSS_UPDATE, (_, css) => { + cb(css); + }); + }, + getQuickCss: () => ipcRenderer.invoke(IPC_GET_QUICK_CSS) +}; \ No newline at end of file diff --git a/src/globals.d.ts b/src/globals.d.ts index 81b04aff..610466a6 100644 --- a/src/globals.d.ts +++ b/src/globals.d.ts @@ -1,9 +1,14 @@ -declare var appSettings: any; +import TVencordNative from "./VencordNative"; declare global { + export var VencordNative: typeof TVencordNative; + export var appSettings: { + set(setting: string, v: any): void; + }; + interface Window { - webpackChunkdiscord_app: { push(chunk): any; }; + webpackChunkdiscord_app: { + push(chunk: any): any; + }; } } - -export { }; \ No newline at end of file diff --git a/src/ipcMain.ts b/src/ipcMain.ts new file mode 100644 index 00000000..c8fba371 --- /dev/null +++ b/src/ipcMain.ts @@ -0,0 +1,25 @@ +import { app, BrowserWindow, ipcMain } from "electron"; +import { fstat, watch } from "fs"; +import { open, readFile } from "fs/promises"; +import { join } from 'path'; +import { IPC_GET_SETTINGS_DIR, IPC_GET_QUICK_CSS, IPC_QUICK_CSS_UPDATE } from './utils/ipcEvents'; + +const DATA_DIR = join(app.getPath("userData"), "..", "Vencord"); +const SETTINGS_DIR = join(DATA_DIR, "settings"); +const QUICKCSS_PATH = join(SETTINGS_DIR, "quickCss.css"); + +function readCss() { + return readFile(QUICKCSS_PATH, "utf-8").catch(() => ""); +} + +ipcMain.handle(IPC_GET_SETTINGS_DIR, () => SETTINGS_DIR); +ipcMain.handle(IPC_GET_QUICK_CSS, () => readCss()); + +export function initIpc(mainWindow: BrowserWindow) { + open(QUICKCSS_PATH, "a+").then(fd => { + fd.close(); + watch(QUICKCSS_PATH, async () => { + mainWindow.webContents.postMessage(IPC_QUICK_CSS_UPDATE, await readCss()); + }); + }); +} diff --git a/src/patcher.ts b/src/patcher.ts index eb45b981..9fe3dd2e 100644 --- a/src/patcher.ts +++ b/src/patcher.ts @@ -2,20 +2,21 @@ import electron, { app, BrowserWindowConstructorOptions } from "electron"; import installExt, { REACT_DEVELOPER_TOOLS } from "electron-devtools-installer"; import { join } from "path"; +import { initIpc } from './ipcMain'; console.log("[Vencord] Starting up..."); class BrowserWindow extends electron.BrowserWindow { - constructor(options: BrowserWindowConstructorOptions) { if (options?.webPreferences?.preload && options.title) { const original = options.webPreferences.preload; options.webPreferences.preload = join(__dirname, "preload.js"); - process.env.APP_PATH = app.getAppPath(); process.env.DISCORD_PRELOAD = original; - } - super(options); + + super(options); + initIpc(this); + } else super(options); } } Object.assign(BrowserWindow, electron.BrowserWindow); @@ -28,10 +29,11 @@ require.cache[electronPath]!.exports = { BrowserWindow }; -// Patch appSettingsa to force enable devtools +// Patch appSettings to force enable devtools Object.defineProperty(global, "appSettings", { - set: (v) => { + set: (v: typeof global.appSettings) => { v.set("DANGEROUS_ENABLE_DEVTOOLS_ONLY_ENABLE_IF_YOU_KNOW_WHAT_YOURE_DOING", true); + // @ts-ignore delete global.appSettings; global.appSettings = v; }, @@ -41,20 +43,17 @@ Object.defineProperty(global, "appSettings", { process.env.DATA_DIR = join(app.getPath("userData"), "..", "Vencord"); electron.app.whenReady().then(() => { - /* installExt(REACT_DEVELOPER_TOOLS) + installExt(REACT_DEVELOPER_TOOLS) .then(() => console.log("Installed React DevTools")) - .catch((err) => console.error("Failed to install React DevTools", err)); */ + .catch((err) => console.error("Failed to install React DevTools", err)); // Remove CSP electron.session.defaultSession.webRequest.onHeadersReceived(({ responseHeaders, url }, cb) => { - if (responseHeaders && url.endsWith(".css")) { + if (responseHeaders) { delete responseHeaders["content-security-policy-report-only"]; delete responseHeaders["content-security-policy"]; - // probably makes github raw work? not tested. - responseHeaders["content-type"] = ["text/css"]; - responseHeaders; } - cb({ cancel: false, responseHeaders: responseHeaders }); + cb({ cancel: false, responseHeaders }); }); // Drop science and sentry requests diff --git a/src/plugins.d.ts b/src/plugins.d.ts new file mode 100644 index 00000000..e2878231 --- /dev/null +++ b/src/plugins.d.ts @@ -0,0 +1,4 @@ +declare module "plugins" { + var plugins: Record[]; + export default plugins; +} \ No newline at end of file diff --git a/src/plugins/bar.ts b/src/plugins/bar.ts new file mode 100644 index 00000000..d503e8a7 --- /dev/null +++ b/src/plugins/bar.ts @@ -0,0 +1,3 @@ +export default { + name: "bar" +}; \ No newline at end of file diff --git a/src/plugins/foo.ts b/src/plugins/foo.ts new file mode 100644 index 00000000..64c9323f --- /dev/null +++ b/src/plugins/foo.ts @@ -0,0 +1,3 @@ +export default { + name: "foo" +}; \ No newline at end of file diff --git a/src/plugins/index.ts b/src/plugins/index.ts new file mode 100644 index 00000000..4e55edbc --- /dev/null +++ b/src/plugins/index.ts @@ -0,0 +1,3 @@ +import plugins from "plugins"; + +console.log(plugins); \ No newline at end of file diff --git a/src/preload.ts b/src/preload.ts index 0fc7430a..73d2eb54 100644 --- a/src/preload.ts +++ b/src/preload.ts @@ -1,14 +1,10 @@ import { contextBridge, webFrame } from "electron"; import { readFileSync } from "fs"; import { join } from "path"; -import Vencord from "./Vencord"; +import VencordNative from "./VencordNative"; -contextBridge.exposeInMainWorld("VencordNative", { - getSettings: () => "hi" -}); +contextBridge.exposeInMainWorld("VencordNative", VencordNative); webFrame.executeJavaScript(readFileSync(join(__dirname, "renderer.js"), "utf-8")); require(process.env.DISCORD_PRELOAD!); - -window.onload = () => console.log("hi"); \ No newline at end of file diff --git a/src/utils/constants.ts b/src/utils/constants.ts index ef008cd7..e9483094 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -1,4 +1 @@ -import { join } from 'path'; - export const WEBPACK_CHUNK = "webpackChunkdiscord_app"; -// export const SETTINGS_DIR = join(process.env.DATA_DIR!, "settings"); diff --git a/src/utils/ipcEvents.ts b/src/utils/ipcEvents.ts new file mode 100644 index 00000000..1920023a --- /dev/null +++ b/src/utils/ipcEvents.ts @@ -0,0 +1,3 @@ +export const IPC_QUICK_CSS_UPDATE = "VencordQuickCssUpdate"; +export const IPC_GET_QUICK_CSS = "VencordGetQuickCss"; +export const IPC_GET_SETTINGS_DIR = "VencordGetSettingsDir"; \ No newline at end of file diff --git a/src/utils/quickCss.ts b/src/utils/quickCss.ts new file mode 100644 index 00000000..573eccc0 --- /dev/null +++ b/src/utils/quickCss.ts @@ -0,0 +1,6 @@ +document.addEventListener("DOMContentLoaded", async () => { + const style = document.createElement("style"); + document.head.appendChild(style); + VencordNative.handleQuickCssUpdate((css: string) => style.innerText = css); + style.innerText = await VencordNative.getQuickCss(); +}); \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index f2d41d09..eb472c98 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,5 +9,5 @@ "noImplicitAny": false, "target": "ESNEXT" }, - "include": ["src/*"] + "include": ["src/**/*.ts"] }