mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-17 13:57:10 +00:00
fix: not signed问题
This commit is contained in:
parent
4df0addffb
commit
89dd029d0e
1 changed files with 24 additions and 14 deletions
|
|
@ -4,6 +4,7 @@ import StealthPlugin from 'puppeteer-extra-plugin-stealth'
|
|||
import { getOpenAIAuth } from './openai-auth.js'
|
||||
import delay from 'delay'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
|
||||
const chatUrl = 'https://chat.openai.com/chat'
|
||||
let puppeteer = {}
|
||||
|
||||
|
|
@ -126,9 +127,9 @@ export class ChatGPTPuppeteer extends Puppeteer {
|
|||
}
|
||||
|
||||
async init () {
|
||||
if (this.inited) {
|
||||
return true
|
||||
}
|
||||
// if (this.inited) {
|
||||
// return true
|
||||
// }
|
||||
try {
|
||||
// this.browser = await getBrowser({
|
||||
// captchaToken: this._captchaToken,
|
||||
|
|
@ -148,13 +149,22 @@ export class ChatGPTPuppeteer extends Puppeteer {
|
|||
await this._page.goto(chatUrl, {
|
||||
waitUntil: 'networkidle2'
|
||||
})
|
||||
try {
|
||||
while ((await this._page.title()).toLowerCase().indexOf('moment') > -1) {
|
||||
// if meet captcha
|
||||
// await this._page.solveRecaptchas()
|
||||
await delay(300)
|
||||
}
|
||||
await delay(300)
|
||||
} catch (e) {
|
||||
// navigation后获取title会报错,报错说明已经在navigation了正合我意。
|
||||
}
|
||||
try {
|
||||
await this._page.waitForNavigation({ timeout: 3000 })
|
||||
} catch (e) {
|
||||
logger.error(e)
|
||||
}
|
||||
if (!await this.getIsAuthenticated()) {
|
||||
await redis.del('CHATGPT:RAW_COOKIES')
|
||||
logger.info('需要登录,准备进行自动化登录')
|
||||
await getOpenAIAuth({
|
||||
email: this._email,
|
||||
|
|
@ -167,7 +177,6 @@ export class ChatGPTPuppeteer extends Puppeteer {
|
|||
} else {
|
||||
logger.info('无需登录')
|
||||
}
|
||||
this.inited = true
|
||||
} catch (err) {
|
||||
if (this.browser) {
|
||||
await this.browser.close()
|
||||
|
|
@ -929,6 +938,7 @@ export async function browserPostEventStream (
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
function hasBom (buffer) {
|
||||
return BOM.every(
|
||||
(charCode, index) => buffer.charCodeAt(index) === charCode
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue