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",
"private": "true",
"version": "1.11.8",
"version": "1.11.9",
"description": "The cutest Discord client mod",
"homepage": "https://github.com/Vendicated/Vencord#readme",
"bugs": {

View file

@ -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");

View file

@ -29,11 +29,8 @@ export const cl = classNameFactory("vc-trans-");
const Native = VencordNative.pluginHelpers.Translate as PluginNative<typeof import("./native")>;
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<TranslationValue> {
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
};
}