diff --git a/package.json b/package.json index bc4d7586..c75345d7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "vencord", "private": "true", - "version": "1.11.8", + "version": "1.11.9", "description": "The cutest Discord client mod", "homepage": "https://github.com/Vendicated/Vencord#readme", "bugs": { diff --git a/src/main/patcher.ts b/src/main/patcher.ts index e5b87290..60b169af 100644 --- a/src/main/patcher.ts +++ b/src/main/patcher.ts @@ -87,6 +87,11 @@ if (!IS_VANILLA) { options.backgroundColor = "#00000000"; } + if (settings.disableMinSize) { + options.minWidth = 0; + options.minHeight = 0; + } + const needsVibrancy = process.platform === "darwin" && settings.macosVibrancyStyle; if (needsVibrancy) { @@ -99,6 +104,12 @@ if (!IS_VANILLA) { process.env.DISCORD_PRELOAD = original; super(options); + + if (settings.disableMinSize) { + // Disable the Electron call entirely so that Discord can't dynamically change the size + this.setMinimumSize = (width: number, height: number) => { }; + } + initIpc(this); } else super(options); } @@ -117,16 +128,9 @@ if (!IS_VANILLA) { BrowserWindow }; - // Patch appSettings to force enable devtools and optionally disable min size + // Patch appSettings to force enable devtools onceDefined(global, "appSettings", s => { s.set("DANGEROUS_ENABLE_DEVTOOLS_ONLY_ENABLE_IF_YOU_KNOW_WHAT_YOURE_DOING", true); - if (settings.disableMinSize) { - s.set("MIN_WIDTH", 0); - s.set("MIN_HEIGHT", 0); - } else { - s.set("MIN_WIDTH", 940); - s.set("MIN_HEIGHT", 500); - } }); process.env.DATA_DIR = join(app.getPath("userData"), "..", "Vencord"); diff --git a/src/plugins/translate/utils.ts b/src/plugins/translate/utils.ts index aff64e8a..9bb175ad 100644 --- a/src/plugins/translate/utils.ts +++ b/src/plugins/translate/utils.ts @@ -29,11 +29,8 @@ export const cl = classNameFactory("vc-trans-"); const Native = VencordNative.pluginHelpers.Translate as PluginNative; interface GoogleData { - src: string; - sentences: { - // 🏳️‍⚧️ - trans: string; - }[]; + translation: string; + sourceLanguage: string; } interface DeeplData { @@ -77,21 +74,13 @@ export async function translate(kind: "received" | "sent", text: string): Promis } async function googleTranslate(text: string, sourceLang: string, targetLang: string): Promise { - const url = "https://translate.googleapis.com/translate_a/single?" + new URLSearchParams({ - // see https://stackoverflow.com/a/29537590 for more params - // holy shidd nvidia - client: "gtx", - // source language - sl: sourceLang, - // target language - tl: targetLang, - // what to return, t = translation probably - dt: "t", - // Send json object response instead of weird array - dj: "1", - source: "input", - // query, duh - q: text + const url = "https://translate-pa.googleapis.com/v1/translate?" + new URLSearchParams({ + "params.client": "gtx", + "dataTypes": "TRANSLATION", + "key": "AIzaSyDLEeFI5OtFBwYBIoK_jj5m32rZK5CkCXA", // some google API key + "query.sourceLanguage": sourceLang, + "query.targetLanguage": targetLang, + "query.text": text, }); const res = await fetch(url); @@ -101,14 +90,11 @@ async function googleTranslate(text: string, sourceLang: string, targetLang: str + `\n${res.status} ${res.statusText}` ); - const { src, sentences }: GoogleData = await res.json(); + const { sourceLanguage, translation }: GoogleData = await res.json(); return { - sourceLanguage: GoogleLanguages[src] ?? src, - text: sentences. - map(s => s?.trans). - filter(Boolean). - join("") + sourceLanguage: GoogleLanguages[sourceLanguage] ?? sourceLanguage, + text: translation }; }