Merge branch 'dev' into strict-csp

This commit is contained in:
Vending Machine 2025-04-14 13:46:53 +02:00 committed by GitHub
commit c7710a0cff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 25 additions and 35 deletions

View file

@ -1,7 +1,7 @@
{ {
"name": "vencord", "name": "vencord",
"private": "true", "private": "true",
"version": "1.11.8", "version": "1.11.9",
"description": "The cutest Discord client mod", "description": "The cutest Discord client mod",
"homepage": "https://github.com/Vendicated/Vencord#readme", "homepage": "https://github.com/Vendicated/Vencord#readme",
"bugs": { "bugs": {

View file

@ -87,6 +87,11 @@ if (!IS_VANILLA) {
options.backgroundColor = "#00000000"; options.backgroundColor = "#00000000";
} }
if (settings.disableMinSize) {
options.minWidth = 0;
options.minHeight = 0;
}
const needsVibrancy = process.platform === "darwin" && settings.macosVibrancyStyle; const needsVibrancy = process.platform === "darwin" && settings.macosVibrancyStyle;
if (needsVibrancy) { if (needsVibrancy) {
@ -99,6 +104,12 @@ if (!IS_VANILLA) {
process.env.DISCORD_PRELOAD = original; process.env.DISCORD_PRELOAD = original;
super(options); 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); initIpc(this);
} else super(options); } else super(options);
} }
@ -117,16 +128,9 @@ if (!IS_VANILLA) {
BrowserWindow BrowserWindow
}; };
// Patch appSettings to force enable devtools and optionally disable min size // Patch appSettings to force enable devtools
onceDefined(global, "appSettings", s => { onceDefined(global, "appSettings", s => {
s.set("DANGEROUS_ENABLE_DEVTOOLS_ONLY_ENABLE_IF_YOU_KNOW_WHAT_YOURE_DOING", true); 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"); process.env.DATA_DIR = join(app.getPath("userData"), "..", "Vencord");

View file

@ -29,11 +29,8 @@ export const cl = classNameFactory("vc-trans-");
const Native = VencordNative.pluginHelpers.Translate as PluginNative<typeof import("./native")>; const Native = VencordNative.pluginHelpers.Translate as PluginNative<typeof import("./native")>;
interface GoogleData { interface GoogleData {
src: string; translation: string;
sentences: { sourceLanguage: string;
// 🏳️‍⚧️
trans: string;
}[];
} }
interface DeeplData { 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<TranslationValue> { async function googleTranslate(text: string, sourceLang: string, targetLang: string): Promise<TranslationValue> {
const url = "https://translate.googleapis.com/translate_a/single?" + new URLSearchParams({ const url = "https://translate-pa.googleapis.com/v1/translate?" + new URLSearchParams({
// see https://stackoverflow.com/a/29537590 for more params "params.client": "gtx",
// holy shidd nvidia "dataTypes": "TRANSLATION",
client: "gtx", "key": "AIzaSyDLEeFI5OtFBwYBIoK_jj5m32rZK5CkCXA", // some google API key
// source language "query.sourceLanguage": sourceLang,
sl: sourceLang, "query.targetLanguage": targetLang,
// target language "query.text": text,
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 res = await fetch(url); const res = await fetch(url);
@ -101,14 +90,11 @@ async function googleTranslate(text: string, sourceLang: string, targetLang: str
+ `\n${res.status} ${res.statusText}` + `\n${res.status} ${res.statusText}`
); );
const { src, sentences }: GoogleData = await res.json(); const { sourceLanguage, translation }: GoogleData = await res.json();
return { return {
sourceLanguage: GoogleLanguages[src] ?? src, sourceLanguage: GoogleLanguages[sourceLanguage] ?? sourceLanguage,
text: sentences. text: translation
map(s => s?.trans).
filter(Boolean).
join("")
}; };
} }