mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-03-31 09:33:03 -06:00
Adjustments
This commit is contained in:
parent
d7b31908d1
commit
2342efcfaa
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
|
|
@ -38,22 +37,7 @@ public class DiscordClient(
|
|||
private TokenKind? _resolvedTokenKind;
|
||||
|
||||
private static string? _xSuperPropertiesHeader;
|
||||
|
||||
private static Guid GenerateLaunchSignature()
|
||||
{
|
||||
var bytes = Guid.NewGuid().ToByteArray();
|
||||
var bits = new BitArray(bytes);
|
||||
|
||||
// Clear the mod-detection bits
|
||||
int[] bitPositions = [119, 108, 100, 91, 84, 75, 61, 55, 48, 38, 24, 11];
|
||||
foreach (int bit in bitPositions)
|
||||
bits[bit] = false;
|
||||
|
||||
bits.CopyTo(bytes, 0);
|
||||
|
||||
return new Guid(bytes);
|
||||
}
|
||||
|
||||
|
||||
// We could generate a random UserAgent. However, that way we could run into issues where certain older or newer versions
|
||||
// and certain browsers could trigger experimental or unsupported features on Discord's site, resulting in the requests potentially failing,
|
||||
// creating impossible to replicate issues for users
|
||||
|
|
@ -64,7 +48,6 @@ public class DiscordClient(
|
|||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//var launchSignature = GenerateLaunchSignature();
|
||||
var buildNumber = await GetBuildNumberAsync();
|
||||
|
||||
if (buildNumber == null)
|
||||
|
|
@ -73,7 +56,7 @@ public class DiscordClient(
|
|||
// https://github.com/greg6775/Discord-Api-Endpoints/blob/master/README.md
|
||||
// https://docs.discord.food/reference#client-properties
|
||||
var json = JsonSerializer.Serialize(
|
||||
new XSuperProperties("Linux", buildNumber ?? ""), // Operating System based on UserAgent
|
||||
new XSuperProperties("Linux", buildNumber), // Operating System based on UserAgent
|
||||
XSuperPropertiesJsonContext.Default.XSuperProperties
|
||||
);
|
||||
|
||||
|
|
@ -86,12 +69,13 @@ public class DiscordClient(
|
|||
|
||||
var response = await Http.Client.SendAsync(
|
||||
request,
|
||||
HttpCompletionOption.ResponseHeadersRead,
|
||||
HttpCompletionOption.ResponseContentRead,
|
||||
cancellationToken
|
||||
);
|
||||
var responseBody = await response.Content.ReadAsStringAsync(cancellationToken);
|
||||
|
||||
// Parse BUILD_NUMBER from the response body
|
||||
// Example being: "<script nonce="...==">window.GLOBAL_ENV = {"NODE_ENV":"production","BUILT_AT":"1773386344946","HTML_TIMESTAMP":Date.now(),"BUILD_NUMBER":"510733","...
|
||||
var buildNumberIndex = responseBody.IndexOf(
|
||||
"\"BUILD_NUMBER\":\"",
|
||||
StringComparison.Ordinal
|
||||
|
|
@ -135,8 +119,6 @@ public class DiscordClient(
|
|||
_xSuperPropertiesHeader ??= await GetXSuperPropertiesHeaderAsync(
|
||||
innerCancellationToken
|
||||
);
|
||||
// If we fail to generate an x-super-properties we should either warn or completely abort this process,
|
||||
// as the user account may be at risk of being flagged?
|
||||
if (_xSuperPropertiesHeader != null)
|
||||
{
|
||||
request.Headers.TryAddWithoutValidation(
|
||||
|
|
@ -144,6 +126,7 @@ public class DiscordClient(
|
|||
_xSuperPropertiesHeader
|
||||
);
|
||||
}
|
||||
|
||||
request.Headers.UserAgent.ParseAdd(UserAgent);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue