kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
Merge pull request #167 from optionsx/Addition_Microsoft_Login
commit
7222b7f296
|
@ -20,6 +20,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
|
|||
protected _debug: boolean
|
||||
protected _minimize: boolean
|
||||
protected _isGoogleLogin: boolean
|
||||
protected _isMicrosoftLogin: boolean
|
||||
protected _captchaToken: string
|
||||
protected _accessToken: string
|
||||
|
||||
|
@ -47,6 +48,9 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
|
|||
/** @defaultValue `false` **/
|
||||
isGoogleLogin?: boolean
|
||||
|
||||
/** @defaultValue `false` **/
|
||||
isMicrosoftLogin?: boolean
|
||||
|
||||
/** @defaultValue `true` **/
|
||||
minimize?: boolean
|
||||
|
||||
|
@ -67,6 +71,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
|
|||
markdown = true,
|
||||
debug = false,
|
||||
isGoogleLogin = false,
|
||||
isMicrosoftLogin = false,
|
||||
minimize = true,
|
||||
captchaToken,
|
||||
executablePath,
|
||||
|
@ -79,6 +84,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
|
|||
this._markdown = !!markdown
|
||||
this._debug = !!debug
|
||||
this._isGoogleLogin = !!isGoogleLogin
|
||||
this._isMicrosoftLogin = !!isMicrosoftLogin
|
||||
this._minimize = !!minimize
|
||||
this._captchaToken = captchaToken
|
||||
this._executablePath = executablePath
|
||||
|
@ -131,7 +137,8 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
|
|||
password: this._password,
|
||||
browser: this._browser,
|
||||
page: this._page,
|
||||
isGoogleLogin: this._isGoogleLogin
|
||||
isGoogleLogin: this._isGoogleLogin,
|
||||
isMicrosoftLogin: this._isMicrosoftLogin
|
||||
})
|
||||
} catch (err) {
|
||||
if (this._browser) {
|
||||
|
@ -144,7 +151,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
|
|||
throw err
|
||||
}
|
||||
|
||||
if (!this.isChatPage || this._isGoogleLogin) {
|
||||
if (!this.isChatPage || this._isGoogleLogin || this._isMicrosoftLogin) {
|
||||
await this._page.goto(CHAT_PAGE_URL, {
|
||||
waitUntil: 'networkidle2'
|
||||
})
|
||||
|
|
|
@ -53,6 +53,7 @@ export async function getOpenAIAuth({
|
|||
page,
|
||||
timeoutMs = 2 * 60 * 1000,
|
||||
isGoogleLogin = false,
|
||||
isMicrosoftLogin = false,
|
||||
captchaToken = process.env.CAPTCHA_TOKEN,
|
||||
nopechaKey = process.env.NOPECHA_KEY,
|
||||
executablePath,
|
||||
|
@ -64,6 +65,7 @@ export async function getOpenAIAuth({
|
|||
page?: Page
|
||||
timeoutMs?: number
|
||||
isGoogleLogin?: boolean
|
||||
isMicrosoftLogin?: boolean
|
||||
captchaToken?: string
|
||||
nopechaKey?: string
|
||||
executablePath?: string
|
||||
|
@ -139,6 +141,23 @@ 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 (isMicrosoftLogin) {
|
||||
await page.click('button[data-provider="windowslive"]')
|
||||
await page.waitForSelector('input[type="email"]')
|
||||
await page.type('input[type="email"]', email, { delay: 10 })
|
||||
await Promise.all([
|
||||
page.waitForNavigation(),
|
||||
await page.keyboard.press('Enter')
|
||||
])
|
||||
await delay(1500)
|
||||
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 delay(1000)
|
||||
} else {
|
||||
await page.waitForSelector('#username')
|
||||
await page.type('#username', email, { delay: 20 })
|
||||
|
@ -328,7 +347,6 @@ export async function getBrowser(
|
|||
const page = (await browser.pages())[0] || (await browser.newPage())
|
||||
await page.goto(`https://nopecha.com/setup#${nopechaKey}`)
|
||||
await delay(1000)
|
||||
|
||||
try {
|
||||
const page3 = await browser.newPage()
|
||||
await page.close()
|
||||
|
|
Ładowanie…
Reference in New Issue