mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Fix poe
This commit is contained in:
@@ -33,8 +33,13 @@ const cached_bots = {};
|
|||||||
|
|
||||||
const logger = console;
|
const logger = console;
|
||||||
|
|
||||||
const user_agent = "Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0";
|
const user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36";
|
||||||
|
|
||||||
|
function unscrambleFormkey(c, code) {
|
||||||
|
var e;
|
||||||
|
eval(code);
|
||||||
|
return e.join('');
|
||||||
|
}
|
||||||
|
|
||||||
function queryScrambler() {
|
function queryScrambler() {
|
||||||
function a(e, t) {
|
function a(e, t) {
|
||||||
@@ -166,7 +171,7 @@ function queryScrambler() {
|
|||||||
return f(d(h(t = _(e)), 8 * t.length))
|
return f(d(h(t = _(e)), 8 * t.length))
|
||||||
}
|
}
|
||||||
function g(e, t) {
|
function g(e, t) {
|
||||||
return function(e, t) {
|
return function (e, t) {
|
||||||
var r, n, i = h(e), a = [], s = [];
|
var r, n, i = h(e), a = [], s = [];
|
||||||
for (a[15] = s[15] = void 0,
|
for (a[15] = s[15] = void 0,
|
||||||
i.length > 16 && (i = d(i, 8 * e.length)),
|
i.length > 16 && (i = d(i, 8 * e.length)),
|
||||||
@@ -284,10 +289,13 @@ class Client {
|
|||||||
|
|
||||||
const r = await request_with_retries(() => this.session.get(this.home_url));
|
const r = await request_with_retries(() => this.session.get(this.home_url));
|
||||||
const jsonRegex = /<script id="__NEXT_DATA__" type="application\/json">(.+?)<\/script>/;
|
const jsonRegex = /<script id="__NEXT_DATA__" type="application\/json">(.+?)<\/script>/;
|
||||||
|
const formKeyRegex = /var c="(.+?)",(.+?),window./;
|
||||||
const jsonText = jsonRegex.exec(r.data)[1];
|
const jsonText = jsonRegex.exec(r.data)[1];
|
||||||
|
const key = formKeyRegex.exec(r.data)[1];
|
||||||
|
const code = formKeyRegex.exec(r.data)[2];
|
||||||
const nextData = JSON.parse(jsonText);
|
const nextData = JSON.parse(jsonText);
|
||||||
|
|
||||||
this.formkey = nextData.props.formkey;
|
this.formkey = unscrambleFormkey(key, code);
|
||||||
this.viewer = nextData.props.pageProps.payload.viewer;
|
this.viewer = nextData.props.pageProps.payload.viewer;
|
||||||
|
|
||||||
return nextData;
|
return nextData;
|
||||||
@@ -335,7 +343,6 @@ class Client {
|
|||||||
const r = await request_with_retries(() => this.session.get(this.settings_url));
|
const r = await request_with_retries(() => this.session.get(this.settings_url));
|
||||||
const data = r.data;
|
const data = r.data;
|
||||||
|
|
||||||
this.formkey = data.formkey;
|
|
||||||
return data.tchannelData;
|
return data.tchannelData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -354,6 +361,7 @@ class Client {
|
|||||||
const scramblePayload = JSON.stringify(payload);
|
const scramblePayload = JSON.stringify(payload);
|
||||||
const _headers = this.gql_headers;
|
const _headers = this.gql_headers;
|
||||||
_headers['poe-tag-id'] = queryScrambler()(scramblePayload + this.formkey + "WpuLMiXEKKE98j56k");
|
_headers['poe-tag-id'] = queryScrambler()(scramblePayload + this.formkey + "WpuLMiXEKKE98j56k");
|
||||||
|
_headers['poe-formkey'] = this.formkey;
|
||||||
const r = await request_with_retries(() => this.session.post(this.gql_url, payload, { headers: this.gql_headers }));
|
const r = await request_with_retries(() => this.session.post(this.gql_url, payload, { headers: this.gql_headers }));
|
||||||
if (!r.data.data) {
|
if (!r.data.data) {
|
||||||
logger.warn(`${queryName} returned an error: ${data.errors[0].message} | Retrying (${i + 1}/20)`);
|
logger.warn(`${queryName} returned an error: ${data.errors[0].message} | Retrying (${i + 1}/20)`);
|
||||||
@@ -452,7 +460,7 @@ class Client {
|
|||||||
for (const message_str of data["messages"]) {
|
for (const message_str of data["messages"]) {
|
||||||
const message_data = JSON.parse(message_str);
|
const message_data = JSON.parse(message_str);
|
||||||
|
|
||||||
if (message_data["message_type"] != "subscriptionUpdate"){
|
if (message_data["message_type"] != "subscriptionUpdate") {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,4 +1,6 @@
|
|||||||
subscription MessageDeletedSubscription($chatId: BigInt!) {
|
subscription subscriptions_messageDeleted_Subscription(
|
||||||
|
$chatId: BigInt!
|
||||||
|
) {
|
||||||
messageDeleted(chatId: $chatId) {
|
messageDeleted(chatId: $chatId) {
|
||||||
id
|
id
|
||||||
messageId
|
messageId
|
||||||
|
@@ -62,6 +62,13 @@ fragment SubscriptionMessageLimitExplanation_viewer on Viewer {
|
|||||||
|
|
||||||
fragment WebSubscriptionPaywall_viewer on Viewer {
|
fragment WebSubscriptionPaywall_viewer on Viewer {
|
||||||
...SubscriptionMessageLimitExplanation_viewer
|
...SubscriptionMessageLimitExplanation_viewer
|
||||||
|
webSubscriptionPriceInfo {
|
||||||
|
monthlyPrice
|
||||||
|
yearlyPrice
|
||||||
|
yearlyPricePerMonth
|
||||||
|
yearlyPercentageSavings
|
||||||
|
id
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fragment WebSubscriptionSuccessMessage_viewer on Viewer {
|
fragment WebSubscriptionSuccessMessage_viewer on Viewer {
|
||||||
|
Reference in New Issue
Block a user