From 7da7cc8b3a99fb5e41e72207ebc592e21527cdfb Mon Sep 17 00:00:00 2001 From: split Date: Thu, 21 Nov 2024 21:02:59 -0800 Subject: [PATCH] feat: :sparkles: discord cookie --- README.md | 1 + src/translators/discord.ts | 20 +++++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 258511e..fbd1767 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ All settings for endpoints are configured in query parameters. ### `/discord` - `token`: Discord token +- `cookie`: Cookie header, b64-encoded ### `/misskey` diff --git a/src/translators/discord.ts b/src/translators/discord.ts index 39e8f1e..9859eb2 100644 --- a/src/translators/discord.ts +++ b/src/translators/discord.ts @@ -2,8 +2,11 @@ import { z } from "zod" import { translator } from "../lib/types.js" import downloadAvatarForPayload from "../lib/downloadAvatarForPayload.js" export default translator({ - query: z.object({ token: z.string().describe("Discord token") }), - async execute(payload, { token }) { + query: z.object({ + token: z.string().describe("Discord token"), + cookie: z.string().describe(`Cookie header, b64-encoded`), + }), + async execute(payload, { token, cookie }) { let avatar = await downloadAvatarForPayload(payload, [ "png", "jpeg", @@ -30,15 +33,22 @@ export default translator({ "X-Super-Properties": Buffer.from( JSON.stringify({ os: "Windows", - browser: "Discord Client", - os_arch: "x64", + browser: "Chrome", + device: "", system_locale: "en-US", - os_version: "10.0.22621", + browser_user_agent: ua, + browser_version, + os_version: "10", + referrer: "", + referring_domain: "", + referrer_current: "", + referring_domain_current: "", release_channel: "stable", client_build_number, client_event_source: null, }) ).toString("base64"), + cookie: Buffer.from(cookie, "base64").toString(), "X-Discord-Locale": "en-US", "X-Discord-Timezone": "America/Los_Angeles", "X-Debug-Options": "bugReporterEnabled",