mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-03-31 17:43:04 -06:00
Adjustments
This commit is contained in:
parent
d7b31908d1
commit
2342efcfaa
|
|
@ -1,5 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
@ -38,22 +37,7 @@ public class DiscordClient(
|
||||||
private TokenKind? _resolvedTokenKind;
|
private TokenKind? _resolvedTokenKind;
|
||||||
|
|
||||||
private static string? _xSuperPropertiesHeader;
|
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
|
// 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,
|
// 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
|
// creating impossible to replicate issues for users
|
||||||
|
|
@ -64,7 +48,6 @@ public class DiscordClient(
|
||||||
CancellationToken cancellationToken = default
|
CancellationToken cancellationToken = default
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//var launchSignature = GenerateLaunchSignature();
|
|
||||||
var buildNumber = await GetBuildNumberAsync();
|
var buildNumber = await GetBuildNumberAsync();
|
||||||
|
|
||||||
if (buildNumber == null)
|
if (buildNumber == null)
|
||||||
|
|
@ -73,7 +56,7 @@ public class DiscordClient(
|
||||||
// https://github.com/greg6775/Discord-Api-Endpoints/blob/master/README.md
|
// https://github.com/greg6775/Discord-Api-Endpoints/blob/master/README.md
|
||||||
// https://docs.discord.food/reference#client-properties
|
// https://docs.discord.food/reference#client-properties
|
||||||
var json = JsonSerializer.Serialize(
|
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
|
XSuperPropertiesJsonContext.Default.XSuperProperties
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -86,12 +69,13 @@ public class DiscordClient(
|
||||||
|
|
||||||
var response = await Http.Client.SendAsync(
|
var response = await Http.Client.SendAsync(
|
||||||
request,
|
request,
|
||||||
HttpCompletionOption.ResponseHeadersRead,
|
HttpCompletionOption.ResponseContentRead,
|
||||||
cancellationToken
|
cancellationToken
|
||||||
);
|
);
|
||||||
var responseBody = await response.Content.ReadAsStringAsync(cancellationToken);
|
var responseBody = await response.Content.ReadAsStringAsync(cancellationToken);
|
||||||
|
|
||||||
// Parse BUILD_NUMBER from the response body
|
// 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(
|
var buildNumberIndex = responseBody.IndexOf(
|
||||||
"\"BUILD_NUMBER\":\"",
|
"\"BUILD_NUMBER\":\"",
|
||||||
StringComparison.Ordinal
|
StringComparison.Ordinal
|
||||||
|
|
@ -135,8 +119,6 @@ public class DiscordClient(
|
||||||
_xSuperPropertiesHeader ??= await GetXSuperPropertiesHeaderAsync(
|
_xSuperPropertiesHeader ??= await GetXSuperPropertiesHeaderAsync(
|
||||||
innerCancellationToken
|
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)
|
if (_xSuperPropertiesHeader != null)
|
||||||
{
|
{
|
||||||
request.Headers.TryAddWithoutValidation(
|
request.Headers.TryAddWithoutValidation(
|
||||||
|
|
@ -144,6 +126,7 @@ public class DiscordClient(
|
||||||
_xSuperPropertiesHeader
|
_xSuperPropertiesHeader
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
request.Headers.UserAgent.ParseAdd(UserAgent);
|
request.Headers.UserAgent.ParseAdd(UserAgent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue