Commit 6733ade3 authored by nanahira's avatar nanahira

no more funcaptcha thanks

parent 8ee5750d
......@@ -243,6 +243,7 @@ async function browserPostEventStream(url2, accessToken, body, timeoutMs) {
});
for await (const chunk of streamAsyncIterable2(res.body)) {
const str = new TextDecoder().decode(chunk);
console.log(`browserPostEventStream chunk: ${str}`);
parser.feed(str);
}
}
......@@ -785,7 +786,6 @@ var ChatGPTAPI = class extends AChatGPTAPI {
// src/chatgpt-api-browser.ts
import delay2 from "delay";
import { getToken } from "funcaptcha";
import { temporaryDirectory } from "tempy";
import { v4 as uuidv42 } from "uuid";
......@@ -1580,7 +1580,12 @@ var ChatGPTAPIBrowser = class extends AChatGPTAPI {
force_paragen: false,
force_rate_limit: false,
history_and_training_disabled: false,
suggestions: [],
suggestions: [
"0",
"1",
"2",
"3"
],
timezone_offset_min: -480
};
if (conversationId) {
......@@ -1616,20 +1621,16 @@ var ChatGPTAPIBrowser = class extends AChatGPTAPI {
}
}
try {
const arkoseThing = await getToken({
pkey: "3D86FBBA-9D22-402A-B512-3420086BA6CC",
surl: "https://tcr9i.chat.openai.com",
headers: {
"User-Agent": await this._page.browser().userAgent()
},
site: "https://chat.openai.com",
proxy: this._proxyServer && (this._proxyServer.startsWith("http") ? this._proxyServer : `http://${this._proxyServer}`)
});
const reqProm = this._page.waitForResponse((res) => res.url() === "https://tcr9i.chat.openai.com/fc/gt2/public_key/3D86FBBA-9D22-402A-B512-3420086BA6CC", { timeout: 1e4 });
const textarea = await this._page.waitForSelector('textarea[id="prompt-textarea"]');
await textarea.type("a");
await this._page.keyboard.press("Backspace");
const req = await reqProm;
result = await this._page.evaluate(
browserPostEventStream,
url2,
this._accessToken,
{ ...body, arkose_token: arkoseThing.token },
{ ...body, arkose_token: (await req.json()).token },
timeoutMs
);
} catch (err) {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
import delay from 'delay'
import { getToken } from 'funcaptcha'
import type { Browser, HTTPRequest, HTTPResponse, Page } from 'puppeteer'
import { temporaryDirectory } from 'tempy'
import { v4 as uuidv4 } from 'uuid'
......@@ -478,7 +477,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
force_paragen: false,
force_rate_limit: false,
history_and_training_disabled: false,
suggestions: [],
suggestions: ['0', '1', '2', '3'],
timezone_offset_min: -480
}
......@@ -521,12 +520,16 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
}
}
// const ua = await this._page.browser().userAgent()
try {
/*
const pkey = '3D86FBBA-9D22-402A-B512-3420086BA6CC'
const arkoseThing = await getToken({
pkey: '3D86FBBA-9D22-402A-B512-3420086BA6CC',
pkey,
surl: 'https://tcr9i.chat.openai.com',
headers: {
'User-Agent': await this._page.browser().userAgent()
'User-Agent': ua
},
site: 'https://chat.openai.com',
proxy:
......@@ -536,12 +539,45 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
: `http://${this._proxyServer}`)
})
const beforeUrlParams = new URLSearchParams({
callback: `__jsonp_${Date.now()}`,
category: 'loaded',
action: 'game loaded',
session_token: arkoseThing.token.split('|')[0],
'data[public_key]' : pkey,
'data[site]': 'https://chat.openai.com',
})
const beforeUrl = `https://tcr9i.chat.openai.com/fc/a/?${beforeUrlParams.toString()
.replaceAll('+', '%20')
.replaceAll('%5B', '[')
.replaceAll('%5D', ']')}`
await this._page.evaluate(async (beforeUrl) => {
await fetch(beforeUrl);
}, beforeUrl)
*/
const reqProm = this._page.waitForResponse(
(res) =>
res.url() ===
'https://tcr9i.chat.openai.com/fc/gt2/public_key/3D86FBBA-9D22-402A-B512-3420086BA6CC',
{ timeout: 10000 }
)
// get text area
const textarea = await this._page.waitForSelector(
'textarea[id="prompt-textarea"]'
)
// type in message and clear it
await textarea.type('a')
await this._page.keyboard.press('Backspace')
const req = await reqProm
// console.log('>>> EVALUATE', url, this._accessToken, body)
result = await this._page.evaluate(
browserPostEventStream,
url,
this._accessToken,
{ ...body, arkose_token: arkoseThing.token },
{ ...body, arkose_token: (await req.json()).token },
timeoutMs
)
} catch (err) {
......
......@@ -228,6 +228,7 @@ export async function browserPostEventStream(
for await (const chunk of streamAsyncIterable(res.body)) {
const str = new TextDecoder().decode(chunk)
console.log(`browserPostEventStream chunk: ${str}`)
parser.feed(str)
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment