Commit ca7dbddc authored by optionsx's avatar optionsx Committed by GitHub

revision of last changes

parent adcb7af5
...@@ -48,7 +48,6 @@ Creates a new client for automating the ChatGPT webapp. ...@@ -48,7 +48,6 @@ Creates a new client for automating the ChatGPT webapp.
| `opts.email` | `string` | - | | `opts.email` | `string` | - |
| `opts.executablePath?` | `string` | **`Default Value`** `undefined` * | | `opts.executablePath?` | `string` | **`Default Value`** `undefined` * |
| `opts.isGoogleLogin?` | `boolean` | **`Default Value`** `false` * | | `opts.isGoogleLogin?` | `boolean` | **`Default Value`** `false` * |
| `opts.isWindowsLogin?` | `boolean` | **`Default Value`** `false` * |
| `opts.markdown?` | `boolean` | **`Default Value`** `true` * | | `opts.markdown?` | `boolean` | **`Default Value`** `true` * |
| `opts.minimize?` | `boolean` | **`Default Value`** `true` * | | `opts.minimize?` | `boolean` | **`Default Value`** `true` * |
| `opts.password` | `string` | - | | `opts.password` | `string` | - |
......
...@@ -262,14 +262,13 @@ Basic Cloudflare CAPTCHAs are handled by default, but if you want to automate th ...@@ -262,14 +262,13 @@ Basic Cloudflare CAPTCHAs are handled by default, but if you want to automate th
- More well-known solution that's been around longer - More well-known solution that's been around longer
- Set the `CAPTCHA_TOKEN` env var to your 2captcha API token - Set the `CAPTCHA_TOKEN` env var to your 2captcha API token
Alternatively, if your OpenAI account uses Google Auth and Microsoft, you shouldn't encounter any of the more complicated Recaptchas — and can avoid using these third-party providers. To use Google auth, make sure your OpenAI account is using Google or Microsoft and then set either `isGoogleLogin` or `isWindowsLogin` to `true` whenever you're passing your `email` and `password`. For example: Alternatively, if your OpenAI account uses Google Auth, you shouldn't encounter any of the more complicated Recaptchas — and can avoid using these third-party providers. To use Google auth, make sure your OpenAI account is using Google and then set `isGoogleLogin` to `true` whenever you're passing your `email` and `password`. For example:
```ts ```ts
const api = new ChatGPTAPIBrowser({ const api = new ChatGPTAPIBrowser({
email: process.env.OPENAI_EMAIL, email: process.env.OPENAI_EMAIL,
password: process.env.OPENAI_PASSWORD, password: process.env.OPENAI_PASSWORD,
isGoogleLogin: true isGoogleLogin: true
isWindowsLogin: true // use only one of this options.
}) })
``` ```
......
...@@ -254,14 +254,13 @@ Basic Cloudflare CAPTCHAs are handled by default, but if you want to automate th ...@@ -254,14 +254,13 @@ Basic Cloudflare CAPTCHAs are handled by default, but if you want to automate th
- More well-known solution that's been around longer - More well-known solution that's been around longer
- Set the `CAPTCHA_TOKEN` env var to your 2captcha API token - Set the `CAPTCHA_TOKEN` env var to your 2captcha API token
Alternatively, if your OpenAI account uses Google Auth and Microsoft, you shouldn't encounter any of the more complicated Recaptchas — and can avoid using these third-party providers. To use Google auth, make sure your OpenAI account is using Google or Microsoft and then set either `isGoogleLogin` or `isWindowsLogin` to `true` whenever you're passing your `email` and `password`. For example: Alternatively, if your OpenAI account uses Google Auth, you shouldn't encounter any of the more complicated Recaptchas — and can avoid using these third-party providers. To use Google auth, make sure your OpenAI account is using Google and then set `isGoogleLogin` to `true` whenever you're passing your `email` and `password`. For example:
```ts ```ts
const api = new ChatGPTAPIBrowser({ const api = new ChatGPTAPIBrowser({
email: process.env.OPENAI_EMAIL, email: process.env.OPENAI_EMAIL,
password: process.env.OPENAI_PASSWORD, password: process.env.OPENAI_PASSWORD,
isGoogleLogin: true isGoogleLogin: true
isWindowsLogin: true // use only one of this options.
}) })
``` ```
......
...@@ -20,7 +20,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI { ...@@ -20,7 +20,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
protected _debug: boolean protected _debug: boolean
protected _minimize: boolean protected _minimize: boolean
protected _isGoogleLogin: boolean protected _isGoogleLogin: boolean
protected _isWindowsLogin: boolean protected _isMicrosoftLogin: boolean
protected _captchaToken: string protected _captchaToken: string
protected _accessToken: string protected _accessToken: string
...@@ -48,7 +48,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI { ...@@ -48,7 +48,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
isGoogleLogin?: boolean isGoogleLogin?: boolean
/** @defaultValue `false` **/ /** @defaultValue `false` **/
isWindowsLogin?: boolean isMicrosoftLogin?: boolean
/** @defaultValue `true` **/ /** @defaultValue `true` **/
minimize?: boolean minimize?: boolean
...@@ -67,7 +67,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI { ...@@ -67,7 +67,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
markdown = true, markdown = true,
debug = false, debug = false,
isGoogleLogin = false, isGoogleLogin = false,
isWindowsLogin = false, isMicrosoftLogin = false,
minimize = true, minimize = true,
captchaToken, captchaToken,
executablePath executablePath
...@@ -79,7 +79,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI { ...@@ -79,7 +79,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
this._markdown = !!markdown this._markdown = !!markdown
this._debug = !!debug this._debug = !!debug
this._isGoogleLogin = !!isGoogleLogin this._isGoogleLogin = !!isGoogleLogin
this._isWindowsLogin = !!isWindowsLogin this._isMicrosoftLogin = !!isMicrosoftLogin
this._minimize = !!minimize this._minimize = !!minimize
this._captchaToken = captchaToken this._captchaToken = captchaToken
this._executablePath = executablePath this._executablePath = executablePath
...@@ -131,7 +131,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI { ...@@ -131,7 +131,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
browser: this._browser, browser: this._browser,
page: this._page, page: this._page,
isGoogleLogin: this._isGoogleLogin, isGoogleLogin: this._isGoogleLogin,
isWindowsLogin: this._isWindowsLogin isMicrosoftLogin: this._isMicrosoftLogin
}) })
} catch (err) { } catch (err) {
if (this._browser) { if (this._browser) {
...@@ -144,7 +144,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI { ...@@ -144,7 +144,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
throw err throw err
} }
if (!this.isChatPage || this._isGoogleLogin || this._isWindowsLogin) { if (!this.isChatPage || this._isGoogleLogin || this._isMicrosoftLogin) {
await this._page.goto(CHAT_PAGE_URL, { await this._page.goto(CHAT_PAGE_URL, {
waitUntil: 'networkidle2' waitUntil: 'networkidle2'
}) })
......
...@@ -53,7 +53,7 @@ export async function getOpenAIAuth({ ...@@ -53,7 +53,7 @@ export async function getOpenAIAuth({
page, page,
timeoutMs = 2 * 60 * 1000, timeoutMs = 2 * 60 * 1000,
isGoogleLogin = false, isGoogleLogin = false,
isWindowsLogin = false, isMicrosoftLogin = false,
captchaToken = process.env.CAPTCHA_TOKEN, captchaToken = process.env.CAPTCHA_TOKEN,
nopechaKey = process.env.NOPECHA_KEY, nopechaKey = process.env.NOPECHA_KEY,
executablePath executablePath
...@@ -64,7 +64,7 @@ export async function getOpenAIAuth({ ...@@ -64,7 +64,7 @@ export async function getOpenAIAuth({
page?: Page page?: Page
timeoutMs?: number timeoutMs?: number
isGoogleLogin?: boolean isGoogleLogin?: boolean
isWindowsLogin?: boolean isMicrosoftLogin?: boolean
captchaToken?: string captchaToken?: string
nopechaKey?: string nopechaKey?: string
executablePath?: string executablePath?: string
...@@ -134,7 +134,7 @@ export async function getOpenAIAuth({ ...@@ -134,7 +134,7 @@ export async function getOpenAIAuth({
await page.waitForSelector('input[type="password"]', { visible: true }) await page.waitForSelector('input[type="password"]', { visible: true })
await page.type('input[type="password"]', password, { delay: 10 }) await page.type('input[type="password"]', password, { delay: 10 })
submitP = () => page.keyboard.press('Enter') submitP = () => page.keyboard.press('Enter')
} else if (isWindowsLogin) { } else if (isMicrosoftLogin) {
await page.click('button[data-provider="windowslive"]') await page.click('button[data-provider="windowslive"]')
await page.waitForSelector('input[type="email"]') await page.waitForSelector('input[type="email"]')
await page.type('input[type="email"]', email, { delay: 10 }) await page.type('input[type="email"]', email, { delay: 10 })
...@@ -146,10 +146,10 @@ export async function getOpenAIAuth({ ...@@ -146,10 +146,10 @@ export async function getOpenAIAuth({
await page.waitForSelector('input[type="password"]', { visible: true }) await page.waitForSelector('input[type="password"]', { visible: true })
await page.type('input[type="password"]', password, { delay: 10 }) await page.type('input[type="password"]', password, { delay: 10 })
submitP = () => page.keyboard.press('Enter') submitP = () => page.keyboard.press('Enter')
await Promise.all([ // await Promise.all([
page.waitForNavigation(), // page.waitForNavigation(),
await page.keyboard.press('Enter') // await page.keyboard.press('Enter')
]) // ])
await delay(1000) await delay(1000)
} else { } else {
await page.waitForSelector('#username') await page.waitForSelector('#username')
......
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