kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
Addition of Microsoft Login.
rodzic
c331c73677
commit
242ea3d4cd
|
@ -20,6 +20,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
|
|||
protected _debug: boolean
|
||||
protected _minimize: boolean
|
||||
protected _isGoogleLogin: boolean
|
||||
protected _isWindowsLogin: boolean
|
||||
protected _captchaToken: string
|
||||
protected _accessToken: string
|
||||
|
||||
|
@ -46,6 +47,9 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
|
|||
/** @defaultValue `false` **/
|
||||
isGoogleLogin?: boolean
|
||||
|
||||
/** @defaultValue `false` **/
|
||||
isWindowsLogin?: boolean
|
||||
|
||||
/** @defaultValue `true` **/
|
||||
minimize?: boolean
|
||||
|
||||
|
@ -63,6 +67,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
|
|||
markdown = true,
|
||||
debug = false,
|
||||
isGoogleLogin = false,
|
||||
isWindowsLogin = false,
|
||||
minimize = true,
|
||||
captchaToken,
|
||||
executablePath
|
||||
|
@ -74,6 +79,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
|
|||
this._markdown = !!markdown
|
||||
this._debug = !!debug
|
||||
this._isGoogleLogin = !!isGoogleLogin
|
||||
this._isWindowsLogin = !!isWindowsLogin
|
||||
this._minimize = !!minimize
|
||||
this._captchaToken = captchaToken
|
||||
this._executablePath = executablePath
|
||||
|
@ -124,7 +130,8 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
|
|||
password: this._password,
|
||||
browser: this._browser,
|
||||
page: this._page,
|
||||
isGoogleLogin: this._isGoogleLogin
|
||||
isGoogleLogin: this._isGoogleLogin,
|
||||
isWindowsLogin: this._isWindowsLogin
|
||||
})
|
||||
} catch (err) {
|
||||
if (this._browser) {
|
||||
|
@ -137,7 +144,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
|
|||
throw err
|
||||
}
|
||||
|
||||
if (!this.isChatPage || this._isGoogleLogin) {
|
||||
if (!this.isChatPage || this._isGoogleLogin || this._isWindowsLogin) {
|
||||
await this._page.goto(CHAT_PAGE_URL, {
|
||||
waitUntil: 'networkidle2'
|
||||
})
|
||||
|
|
|
@ -53,6 +53,7 @@ export async function getOpenAIAuth({
|
|||
page,
|
||||
timeoutMs = 2 * 60 * 1000,
|
||||
isGoogleLogin = false,
|
||||
isWindowsLogin = false,
|
||||
captchaToken = process.env.CAPTCHA_TOKEN,
|
||||
nopechaKey = process.env.NOPECHA_KEY,
|
||||
executablePath
|
||||
|
@ -63,6 +64,7 @@ export async function getOpenAIAuth({
|
|||
page?: Page
|
||||
timeoutMs?: number
|
||||
isGoogleLogin?: boolean
|
||||
isWindowsLogin?: boolean
|
||||
captchaToken?: string
|
||||
nopechaKey?: string
|
||||
executablePath?: string
|
||||
|
@ -132,6 +134,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 (isWindowsLogin) {
|
||||
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 })
|
||||
|
@ -293,7 +312,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