Commit 97fef500 authored by nanahira's avatar nanahira

updates

parent e3a96b68
...@@ -47,7 +47,7 @@ async function fetchSSE(url2, options) { ...@@ -47,7 +47,7 @@ async function fetchSSE(url2, options) {
const { onMessage, ...fetchOptions } = options; const { onMessage, ...fetchOptions } = options;
const res = await fetch2(url2, fetchOptions); const res = await fetch2(url2, fetchOptions);
if (!res.ok) { if (!res.ok) {
const msg = `ChatGPTAPI error ${res.status || res.statusText}`; const msg = `ChatGPTAPI error ${res.status || res.statusText} ${res.json()}`;
const error = new ChatGPTError(msg); const error = new ChatGPTError(msg);
error.statusCode = res.status; error.statusCode = res.status;
error.statusText = res.statusText; error.statusText = res.statusText;
...@@ -906,8 +906,8 @@ async function getOpenAIAuth({ ...@@ -906,8 +906,8 @@ async function getOpenAIAuth({
]); ]);
await delay(1e3); await delay(1e3);
} else { } else {
await page.waitForSelector("#username"); await page.waitForSelector("#email-input");
await page.type("#username", email); await page.type("#email-input", email);
await delay(100); await delay(100);
if (!hasRecaptchaPlugin) { if (!hasRecaptchaPlugin) {
await waitForRecaptcha(page, { timeoutMs }); await waitForRecaptcha(page, { timeoutMs });
...@@ -931,20 +931,19 @@ async function getOpenAIAuth({ ...@@ -931,20 +931,19 @@ async function getOpenAIAuth({
} }
await delay(2e3); await delay(2e3);
const frame = page.mainFrame(); const frame = page.mainFrame();
const continueSelector = ".continue-btn";
const submit = await page.waitForSelector( const submit = await page.waitForSelector(
'button[type="submit"][data-action-button-primary="true"]', continueSelector,
{ {
timeout: timeoutMs timeout: timeoutMs
} }
); );
await frame.focus( await frame.focus(continueSelector);
'button[type="submit"][data-action-button-primary="true"]'
);
await submit.focus(); await submit.focus();
await submit.click(); await submit.click();
await page.waitForSelector("#password", { timeout: timeoutMs }); await page.waitForSelector("#password", { timeout: timeoutMs });
await page.type("#password", password); await page.type("#password", password);
await delay(1e4); await delay(5e3);
submitP = async () => { submitP = async () => {
await page.click( await page.click(
'button[type="submit"][data-action-button-primary="true"]' 'button[type="submit"][data-action-button-primary="true"]'
...@@ -1651,10 +1650,8 @@ var ChatGPTAPIBrowser = class extends AChatGPTAPI { ...@@ -1651,10 +1650,8 @@ var ChatGPTAPIBrowser = class extends AChatGPTAPI {
} else if (error.statusCode !== 403) { } else if (error.statusCode !== 403) {
throw error; throw error;
} else if (numTries >= 2) { } else if (numTries >= 2) {
await this.refreshSession();
throw error; throw error;
} else { } else {
await this.refreshSession();
await delay2(1e3); await delay2(1e3);
result = null; result = null;
continue; continue;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -621,10 +621,10 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI { ...@@ -621,10 +621,10 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
} else if (error.statusCode !== 403) { } else if (error.statusCode !== 403) {
throw error throw error
} else if (numTries >= 2) { } else if (numTries >= 2) {
await this.refreshSession() //await this.refreshSession()
throw error throw error
} else { } else {
await this.refreshSession() //await this.refreshSession()
await delay(1000) await delay(1000)
result = null result = null
continue continue
......
...@@ -11,7 +11,7 @@ export async function fetchSSE( ...@@ -11,7 +11,7 @@ export async function fetchSSE(
const { onMessage, ...fetchOptions } = options const { onMessage, ...fetchOptions } = options
const res = await fetch(url, fetchOptions) const res = await fetch(url, fetchOptions)
if (!res.ok) { if (!res.ok) {
const msg = `ChatGPTAPI error ${res.status || res.statusText}` const msg = `ChatGPTAPI error ${res.status || res.statusText} ${res.json()}`
const error = new types.ChatGPTError(msg) const error = new types.ChatGPTError(msg)
error.statusCode = res.status error.statusCode = res.status
error.statusText = res.statusText error.statusText = res.statusText
......
...@@ -176,8 +176,8 @@ export async function getOpenAIAuth({ ...@@ -176,8 +176,8 @@ export async function getOpenAIAuth({
]) ])
await delay(1000) await delay(1000)
} else { } else {
await page.waitForSelector('#username') await page.waitForSelector('#email-input')
await page.type('#username', email) await page.type('#email-input', email)
await delay(100) await delay(100)
// NOTE: this is where you may encounter a CAPTCHA // NOTE: this is where you may encounter a CAPTCHA
...@@ -206,20 +206,17 @@ export async function getOpenAIAuth({ ...@@ -206,20 +206,17 @@ export async function getOpenAIAuth({
await delay(2000) await delay(2000)
const frame = page.mainFrame() const frame = page.mainFrame()
const submit = await page.waitForSelector( // a button, with class continue-btn
'button[type="submit"][data-action-button-primary="true"]', const continueSelector = '.continue-btn'
{ const submit = await page.waitForSelector(continueSelector, {
timeout: timeoutMs timeout: timeoutMs
} })
) await frame.focus(continueSelector)
await frame.focus(
'button[type="submit"][data-action-button-primary="true"]'
)
await submit.focus() await submit.focus()
await submit.click() await submit.click()
await page.waitForSelector('#password', { timeout: timeoutMs }) await page.waitForSelector('#password', { timeout: timeoutMs })
await page.type('#password', password) await page.type('#password', password)
await delay(10000) await delay(5000)
submitP = async () => { submitP = async () => {
//console.log('1st click') //console.log('1st click')
await page.click( await page.click(
......
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