Move away from using webpack for gettign lang

This commit is contained in:
smartfrigde 2022-09-27 13:04:18 +00:00
parent 4613f77f30
commit 7b25fc70c9
3 changed files with 5 additions and 6 deletions

View file

@ -7,6 +7,7 @@
"build": "tsc && copyfiles -u 1 src/**/*.html src/**/**/*.css ts-out/ && copyfiles package.json ts-out/ && copyfiles assets/**/** ts-out/",
"watch": "tsc -w",
"start": "npm run build && electron ./ts-out/main.js",
"startNoSandbox": "npm run build && electron ./ts-out/main.js --no-sandbox",
"package": "npm run build && electron-builder",
"packageQuick": "npm run build && electron-builder --dir",
"format": "prettier --write src/**/*",

View file

@ -15,7 +15,6 @@ contextBridge.exposeInMainWorld("armcord", {
},
electron: process.versions.electron,
channel: ipcRenderer.sendSync("channel"),
setLang: (lang: string) => ipcRenderer.send("setLang", lang),
setPingCount: (pingCount: number) => ipcRenderer.send("setPing", pingCount),
setTrayIcon: (favicon: string) => ipcRenderer.send("sendTrayIcon", favicon),
getLang: (toGet: string) =>

View file

@ -4,7 +4,7 @@ import "./patch";
import * as fs from "fs";
import * as path from "path";
import {injectHummusTitlebar, injectTitlebar} from "./titlebar";
import {sleep, addStyle, injectJS, addScript} from "../utils";
import {sleep, addStyle, injectJS} from "../utils";
import {ipcRenderer} from "electron";
import {injectMobileStuff} from "./mobile";
var version = ipcRenderer.sendSync("displayVersion");
@ -13,10 +13,9 @@ async function updateLang() {
if (window.location.href.indexOf("setup.html") > -1) {
console.log("Setup, skipping lang update");
} else {
// addScript(`function getDiscordLang() {
// {const _w=webpackChunkdiscord_app;let lang;_w.push([[Symbol()],{},e=>{for(const k in e.c){const m=e.c[k].exports;const mDef=m?.default&&m.__esModule?m.default:m;if(mDef?._chosenLocale&&!lang)lang=mDef}}]);_w.pop();window.armcord.setLang(lang._chosenLocale);return lang._chosenLocale;void 0}}
// getDiscordLang();`);
// haha get patched kid
const value = `; ${document.cookie}`;
const parts: any = value.split(`; locale=`);
if (parts.length === 2) ipcRenderer.send("setLang", parts.pop().split(";").shift());
}
}
declare global {