mirror of
https://github.com/smartfrigde/armcord.git
synced 2024-08-14 23:56:58 +00:00
fix arRPC
This commit is contained in:
parent
4cb480cf93
commit
0dfb518082
3 changed files with 83 additions and 71 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
window.addEventListener(
|
||||||
|
"load",
|
||||||
(() => {
|
(() => {
|
||||||
let Dispatcher,
|
let Dispatcher,
|
||||||
lookupAsset,
|
lookupAsset,
|
||||||
|
@ -15,43 +17,47 @@
|
||||||
|
|
||||||
for (const id in cache) {
|
for (const id in cache) {
|
||||||
let mod = cache[id].exports;
|
let mod = cache[id].exports;
|
||||||
mod = mod && (mod.Z ?? mod.ZP);
|
for (const prop in mod) {
|
||||||
|
const candidate = mod[prop];
|
||||||
if (mod && mod.register && mod.wait) {
|
if (candidate && candidate.register && candidate.wait) {
|
||||||
Dispatcher = mod;
|
Dispatcher = candidate;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (Dispatcher) break; // make sure to exit outer loop as well
|
||||||
|
}
|
||||||
|
|
||||||
const factories = wpRequire.m;
|
const factories = wpRequire.m;
|
||||||
for (const id in factories) {
|
for (const id in factories) {
|
||||||
if (factories[id].toString().includes("getAssetImage: size must === [number, number] for Twitch")) {
|
if (factories[id].toString().includes("getAssetImage: size must === [number, number] for Twitch")) {
|
||||||
const mod = wpRequire(id);
|
const mod = wpRequire(id);
|
||||||
|
|
||||||
|
// fetchAssetIds
|
||||||
const _lookupAsset = Object.values(mod).find(
|
const _lookupAsset = Object.values(mod).find(
|
||||||
(e) => typeof e === "function" && e.toString().includes("apply(")
|
(e) => typeof e === "function" && e.toString().includes("APPLICATION_ASSETS_FETCH_SUCCESS")
|
||||||
);
|
);
|
||||||
|
if (_lookupAsset)
|
||||||
lookupAsset = async (appId, name) => (await _lookupAsset(appId, [name, undefined]))[0];
|
lookupAsset = async (appId, name) => (await _lookupAsset(appId, [name, undefined]))[0];
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
if (lookupAsset) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const id in factories) {
|
for (const id in factories) {
|
||||||
if (factories[id].toString().includes(`e.application={`)) {
|
if (factories[id].toString().includes("APPLICATION_RPC")) {
|
||||||
const mod = wpRequire(id);
|
const mod = wpRequire(id);
|
||||||
|
|
||||||
|
// fetchApplicationsRPC
|
||||||
const _lookupApp = Object.values(mod).find(
|
const _lookupApp = Object.values(mod).find(
|
||||||
(e) => typeof e === "function" && e.toString().includes(`e.application={`)
|
(e) => typeof e === "function" && e.toString().includes(",coverImage:")
|
||||||
);
|
);
|
||||||
|
if (_lookupApp)
|
||||||
lookupApp = async (appId) => {
|
lookupApp = async (appId) => {
|
||||||
let socket = {};
|
let socket = {};
|
||||||
await _lookupApp(socket, appId);
|
await _lookupApp(socket, appId);
|
||||||
return socket.application;
|
return socket.application;
|
||||||
};
|
};
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
if (lookupApp) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,6 +72,7 @@
|
||||||
msg.activity.assets.small_image
|
msg.activity.assets.small_image
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// prevent errors when activity is null and let activity stop
|
||||||
if (msg.activity) {
|
if (msg.activity) {
|
||||||
const appId = msg.activity.application_id;
|
const appId = msg.activity.application_id;
|
||||||
if (!apps[appId]) apps[appId] = await lookupApp(appId);
|
if (!apps[appId]) apps[appId] = await lookupApp(appId);
|
||||||
|
@ -76,4 +83,5 @@
|
||||||
|
|
||||||
Dispatcher.dispatch({type: "LOCAL_ACTIVITY_UPDATE", ...msg}); // set RPC status
|
Dispatcher.dispatch({type: "LOCAL_ACTIVITY_UPDATE", ...msg}); // set RPC status
|
||||||
});
|
});
|
||||||
})();
|
})()
|
||||||
|
);
|
||||||
|
|
|
@ -67,5 +67,6 @@ contextBridge.exposeInMainWorld("ArmCordRPC", {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ipcRenderer.on("rpc", (_event, data: object) => {
|
ipcRenderer.on("rpc", (_event, data: object) => {
|
||||||
|
console.log(data);
|
||||||
windowCallback(data);
|
windowCallback(data);
|
||||||
});
|
});
|
||||||
|
|
|
@ -73,7 +73,10 @@ sleep(5000).then(async () => {
|
||||||
|
|
||||||
// Settings info version injection
|
// Settings info version injection
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
const host = document.querySelector<HTMLDivElement>("nav > [class|=side] [class|=info]");
|
// @ts-expect-error
|
||||||
|
const host = [...document.querySelectorAll('[class*="sidebar"] [class*="info"] [class*="line"]')].find((x) =>
|
||||||
|
x.textContent.startsWith("Host ")
|
||||||
|
);
|
||||||
if (!host || host.querySelector("#ac-ver")) {
|
if (!host || host.querySelector("#ac-ver")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -84,8 +87,8 @@ setInterval(() => {
|
||||||
el.onclick = () => ipcRenderer.send("openSettingsWindow");
|
el.onclick = () => ipcRenderer.send("openSettingsWindow");
|
||||||
host.append(el);
|
host.append(el);
|
||||||
let advanced = document
|
let advanced = document
|
||||||
.querySelector('[class*="socialLinks-"]')!
|
.querySelector('[class*="socialLinks"]')
|
||||||
.parentElement!.querySelector(
|
?.parentElement?.querySelector(
|
||||||
'[class*="header"] + [class*="item"] + [class*="item"] + [class*="item"] + [class*="item"] + [class*="item"] + [class*="item"] + [class*="item"] + [class*="item"] + [class*="item"]'
|
'[class*="header"] + [class*="item"] + [class*="item"] + [class*="item"] + [class*="item"] + [class*="item"] + [class*="item"] + [class*="item"] + [class*="item"] + [class*="item"]'
|
||||||
);
|
);
|
||||||
if (!advanced) return;
|
if (!advanced) return;
|
||||||
|
|
Loading…
Reference in a new issue