Merge remote-tracking branch 'upstream/dev' into dev
Some checks are pending
Test / Test (push) Waiting to run

This commit is contained in:
thororen1234 2025-05-16 18:20:03 -04:00
commit 317916a5b1
No known key found for this signature in database
4 changed files with 45 additions and 10 deletions

View file

@ -17,9 +17,10 @@
*/ */
function parseHeaders(headers) { function parseHeaders(headers) {
const result = new Headers();
if (!headers) if (!headers)
return {}; return result;
const result = {};
const headersArr = headers.trim().split("\n"); const headersArr = headers.trim().split("\n");
for (var i = 0; i < headersArr.length; i++) { for (var i = 0; i < headersArr.length; i++) {
var row = headersArr[i]; var row = headersArr[i];
@ -27,13 +28,7 @@ function parseHeaders(headers) {
, key = row.slice(0, index).trim().toLowerCase() , key = row.slice(0, index).trim().toLowerCase()
, value = row.slice(index + 1).trim(); , value = row.slice(index + 1).trim();
if (result[key] === undefined) { result.append(key, value);
result[key] = value;
} else if (Array.isArray(result[key])) {
result[key].push(value);
} else {
result[key] = [result[key], value];
}
} }
return result; return result;
} }

View file

@ -9,6 +9,7 @@
// @license GPL-3.0 // @license GPL-3.0
// @match *://*.discord.com/* // @match *://*.discord.com/*
// @grant GM_xmlhttpRequest // @grant GM_xmlhttpRequest
// @grant unsafeWindow
// @run-at document-start // @run-at document-start
// @compatible chrome Chrome + Tampermonkey or Violentmonkey // @compatible chrome Chrome + Tampermonkey or Violentmonkey
// @compatible firefox Firefox Tampermonkey // @compatible firefox Firefox Tampermonkey

View file

@ -74,6 +74,22 @@ function makeShortcuts() {
}; };
} }
function findStoreWrapper(findStore: typeof Webpack.findStore) {
const cache = new Map<string, unknown>();
return function (storeName: string) {
const cacheKey = String(storeName);
if (cache.has(cacheKey)) return cache.get(cacheKey);
let store: unknown;
try {
store = findStore(storeName);
} catch { }
if (store) cache.set(cacheKey, store);
return store;
};
}
let fakeRenderWin: WeakRef<Window> | undefined; let fakeRenderWin: WeakRef<Window> | undefined;
const find = newFindWrapper(f => f); const find = newFindWrapper(f => f);
const findByProps = newFindWrapper(filters.byProps); const findByProps = newFindWrapper(filters.byProps);
@ -98,7 +114,7 @@ function makeShortcuts() {
findComponentByCode: newFindWrapper(filters.componentByCode), findComponentByCode: newFindWrapper(filters.componentByCode),
findAllComponentsByCode: (...code: string[]) => findAll(filters.componentByCode(...code)), findAllComponentsByCode: (...code: string[]) => findAll(filters.componentByCode(...code)),
findExportedComponent: (...props: string[]) => findByProps(...props)[props[0]], findExportedComponent: (...props: string[]) => findByProps(...props)[props[0]],
findStore: newFindWrapper(filters.byStoreName), findStore: findStoreWrapper(Webpack.findStore),
PluginsApi: { getter: () => Vencord.Plugins }, PluginsApi: { getter: () => Vencord.Plugins },
plugins: { getter: () => Vencord.Plugins.plugins }, plugins: { getter: () => Vencord.Plugins.plugins },
Settings: { getter: () => Vencord.Settings }, Settings: { getter: () => Vencord.Settings },

View file

@ -470,6 +470,29 @@ export function findStore(name: StoreNameFilter) {
} }
} }
try {
const getLibdiscore = findByCode("libdiscoreWasm is not initialized");
const libdiscoreExports = getLibdiscore();
for (const libdiscoreExportName in libdiscoreExports) {
if (!libdiscoreExportName.endsWith("Store")) {
continue;
}
const storeName = libdiscoreExportName;
const store = libdiscoreExports[storeName];
if (storeName === name) {
res = store;
}
if (fluxStores[storeName] == null) {
fluxStores[storeName] = store;
}
}
} catch { }
if (res == null) { if (res == null) {
res = find(filters.byStoreName(name), { isIndirect: true }); res = find(filters.byStoreName(name), { isIndirect: true });
} }