From d730db2ea251a1fbc60f1fb7b49085a20ee460ac Mon Sep 17 00:00:00 2001 From: adryd Date: Wed, 11 Feb 2026 20:10:18 -0500 Subject: [PATCH] Update snippet to use findByCode (#1) The previous snippet uses variables that might change in future discord builds Co-authored-by: NotNite --- src/routes/+page.svelte | 52 +++++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 9ebc2b6..a17bf81 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -32,30 +32,48 @@ up (typing "allow pasting" before if necessary):

-
// add a chunk to get all of the webpack chunks
-_mods = webpackChunkdiscord_app.push([[Symbol()],{},r=>r.c]);
-webpackChunkdiscord_app.pop(); // cleanup the chunk we added
+	
+// add a chunk to extract webpack's moduleCache
+let webpackRequire = webpackChunkdiscord_app.push([[Symbol()],{},(r) => r]);
+// cleanup the chunk we added
+webpackChunkdiscord_app.pop();
 
-// utility to find a webpack chunk by property
-findByProps = (...props) => {
-    for (let m of Object.values(_mods)) {
-        try {
-            if (!m.exports || m.exports === window) continue;
-            if (props.every((x) => m.exports?.[x])) return m.exports;
+let modules = webpackRequire.m;
+let cache = webpackRequire.c;
 
-            for (let ex in m.exports) {
-                if (props.every((x) => m.exports?.[ex]?.[x]) && m.exports[ex][Symbol.toStringTag] !== 'IntlMessagesProxy') return m.exports[ex];
-            }
-        } catch {}
-    }
-}
+// https://github.com/moonlight-mod/moonlight/blob/main/packages/core-extensions/src/spacepack/webpackModules/spacepack.ts
+// helper to find a webpack module via code snippet
+function findByCode(src) {
+  for (const [id, mod] of Object.entries(modules)) {
+    if (mod.toString().includes(src)) {
+      return cache[id].exports;
+    }
+  }
+}
 
+// helper to find an object by its key
+function findObjectFromKey(exports, key) {
+  if (!exports) return;
+  for (const exportKey in exports) {
+    const obj = exports[exportKey];
+    if (obj && obj[key]) return obj;
+  }
+}
 
+// https://github.com/moonlight-mod/moonlight/blob/main/packages/mappings/src/mappings/discord/utils/HTTPUtils.ts
 // find the discord api client
-api = findByProps('Bo','oh').Bo
+const api = findObjectFromKey(
+  findByCode('.set("X-Audit-Log-Reason",'),
+  "patch",
+);
 
 // send a api request to discord /age-verification/verify and then redirect the page to our website
-window.location.href = `https://age-verifier.kibty.town/webview?url=${encodeURIComponent((await api.post({ url: '/age-verification/verify', body: { method: 3 }})).body.verification_webview_url)}`
+const request = await api.post({ + url: "/age-verification/verify", + body: { method: 3 }, +}); +const verificationUrl = request.body.verification_webview_url; +window.location.href = `https://age-verifier.kibty.town/webview?url=${encodeURIComponent(verificationUrl)}`;

(feel free to read the code, we made it readable and we have nothing to hide)