Skip to content

Commit

Permalink
revision of last changes
Browse files Browse the repository at this point in the history
  • Loading branch information
optionsx authored Dec 18, 2022
1 parent adcb7af commit ca7dbdd
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 18 deletions.
1 change: 0 additions & 1 deletion docs/classes/ChatGPTAPIBrowser.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ Creates a new client for automating the ChatGPT webapp.
| `opts.email` | `string` | - |
| `opts.executablePath?` | `string` | **`Default Value`** `undefined` * |
| `opts.isGoogleLogin?` | `boolean` | **`Default Value`** `false` * |
| `opts.isWindowsLogin?` | `boolean` | **`Default Value`** `false` * |
| `opts.markdown?` | `boolean` | **`Default Value`** `true` * |
| `opts.minimize?` | `boolean` | **`Default Value`** `true` * |
| `opts.password` | `string` | - |
Expand Down
3 changes: 1 addition & 2 deletions docs/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
- 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
const api = new ChatGPTAPIBrowser({
email: process.env.OPENAI_EMAIL,
password: process.env.OPENAI_PASSWORD,
isGoogleLogin: true
isWindowsLogin: true // use only one of this options.
})
```

Expand Down
3 changes: 1 addition & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
- 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
const api = new ChatGPTAPIBrowser({
email: process.env.OPENAI_EMAIL,
password: process.env.OPENAI_PASSWORD,
isGoogleLogin: true
isWindowsLogin: true // use only one of this options.
})
```

Expand Down
12 changes: 6 additions & 6 deletions src/chatgpt-api-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
protected _debug: boolean
protected _minimize: boolean
protected _isGoogleLogin: boolean
protected _isWindowsLogin: boolean
protected _isMicrosoftLogin: boolean
protected _captchaToken: string
protected _accessToken: string

Expand Down Expand Up @@ -48,7 +48,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
isGoogleLogin?: boolean

/** @defaultValue `false` **/
isWindowsLogin?: boolean
isMicrosoftLogin?: boolean

/** @defaultValue `true` **/
minimize?: boolean
Expand All @@ -67,7 +67,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
markdown = true,
debug = false,
isGoogleLogin = false,
isWindowsLogin = false,
isMicrosoftLogin = false,
minimize = true,
captchaToken,
executablePath
Expand All @@ -79,7 +79,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
this._markdown = !!markdown
this._debug = !!debug
this._isGoogleLogin = !!isGoogleLogin
this._isWindowsLogin = !!isWindowsLogin
this._isMicrosoftLogin = !!isMicrosoftLogin
this._minimize = !!minimize
this._captchaToken = captchaToken
this._executablePath = executablePath
Expand Down Expand Up @@ -131,7 +131,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
browser: this._browser,
page: this._page,
isGoogleLogin: this._isGoogleLogin,
isWindowsLogin: this._isWindowsLogin
isMicrosoftLogin: this._isMicrosoftLogin
})
} catch (err) {
if (this._browser) {
Expand All @@ -144,7 +144,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
throw err
}

if (!this.isChatPage || this._isGoogleLogin || this._isWindowsLogin) {
if (!this.isChatPage || this._isGoogleLogin || this._isMicrosoftLogin) {
await this._page.goto(CHAT_PAGE_URL, {
waitUntil: 'networkidle2'
})
Expand Down
14 changes: 7 additions & 7 deletions src/openai-auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export async function getOpenAIAuth({
page,
timeoutMs = 2 * 60 * 1000,
isGoogleLogin = false,
isWindowsLogin = false,
isMicrosoftLogin = false,
captchaToken = process.env.CAPTCHA_TOKEN,
nopechaKey = process.env.NOPECHA_KEY,
executablePath
Expand All @@ -64,7 +64,7 @@ export async function getOpenAIAuth({
page?: Page
timeoutMs?: number
isGoogleLogin?: boolean
isWindowsLogin?: boolean
isMicrosoftLogin?: boolean
captchaToken?: string
nopechaKey?: string
executablePath?: string
Expand Down Expand Up @@ -134,7 +134,7 @@ export async function getOpenAIAuth({
await page.waitForSelector('input[type="password"]', { visible: true })
await page.type('input[type="password"]', password, { delay: 10 })
submitP = () => page.keyboard.press('Enter')
} else if (isWindowsLogin) {
} else if (isMicrosoftLogin) {
await page.click('button[data-provider="windowslive"]')
await page.waitForSelector('input[type="email"]')
await page.type('input[type="email"]', email, { delay: 10 })
Expand All @@ -146,10 +146,10 @@ export async function getOpenAIAuth({
await page.waitForSelector('input[type="password"]', { visible: true })
await page.type('input[type="password"]', password, { delay: 10 })
submitP = () => page.keyboard.press('Enter')
await Promise.all([
page.waitForNavigation(),
await page.keyboard.press('Enter')
])
// await Promise.all([
// page.waitForNavigation(),
// await page.keyboard.press('Enter')
// ])
await delay(1000)
} else {
await page.waitForSelector('#username')
Expand Down

0 comments on commit ca7dbdd

Please sign in to comment.