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 _debug: boolean
|
||||||
protected _minimize: boolean
|
protected _minimize: boolean
|
||||||
protected _isGoogleLogin: boolean
|
protected _isGoogleLogin: boolean
|
||||||
|
protected _isMicrosoftLogin: boolean
|
||||||
protected _captchaToken: string
|
protected _captchaToken: string
|
||||||
protected _accessToken: string
|
protected _accessToken: string
|
||||||
|
|
||||||
|
@ -47,6 +48,9 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
|
||||||
/** @defaultValue `false` **/
|
/** @defaultValue `false` **/
|
||||||
isGoogleLogin?: boolean
|
isGoogleLogin?: boolean
|
||||||
|
|
||||||
|
/** @defaultValue `false` **/
|
||||||
|
isMicrosoftLogin?: boolean
|
||||||
|
|
||||||
/** @defaultValue `true` **/
|
/** @defaultValue `true` **/
|
||||||
minimize?: boolean
|
minimize?: boolean
|
||||||
|
|
||||||
|
@ -67,6 +71,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
|
||||||
markdown = true,
|
markdown = true,
|
||||||
debug = false,
|
debug = false,
|
||||||
isGoogleLogin = false,
|
isGoogleLogin = false,
|
||||||
|
isMicrosoftLogin = false,
|
||||||
minimize = true,
|
minimize = true,
|
||||||
captchaToken,
|
captchaToken,
|
||||||
executablePath,
|
executablePath,
|
||||||
|
@ -79,6 +84,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._isMicrosoftLogin = !!isMicrosoftLogin
|
||||||
this._minimize = !!minimize
|
this._minimize = !!minimize
|
||||||
this._captchaToken = captchaToken
|
this._captchaToken = captchaToken
|
||||||
this._executablePath = executablePath
|
this._executablePath = executablePath
|
||||||
|
@ -131,7 +137,8 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
|
||||||
password: this._password,
|
password: this._password,
|
||||||
browser: this._browser,
|
browser: this._browser,
|
||||||
page: this._page,
|
page: this._page,
|
||||||
isGoogleLogin: this._isGoogleLogin
|
isGoogleLogin: this._isGoogleLogin,
|
||||||
|
isMicrosoftLogin: this._isMicrosoftLogin
|
||||||
})
|
})
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (this._browser) {
|
if (this._browser) {
|
||||||
|
@ -144,7 +151,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
|
||||||
throw err
|
throw err
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.isChatPage || this._isGoogleLogin) {
|
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,6 +53,7 @@ export async function getOpenAIAuth({
|
||||||
page,
|
page,
|
||||||
timeoutMs = 2 * 60 * 1000,
|
timeoutMs = 2 * 60 * 1000,
|
||||||
isGoogleLogin = false,
|
isGoogleLogin = 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,6 +65,7 @@ export async function getOpenAIAuth({
|
||||||
page?: Page
|
page?: Page
|
||||||
timeoutMs?: number
|
timeoutMs?: number
|
||||||
isGoogleLogin?: boolean
|
isGoogleLogin?: boolean
|
||||||
|
isMicrosoftLogin?: boolean
|
||||||
captchaToken?: string
|
captchaToken?: string
|
||||||
nopechaKey?: string
|
nopechaKey?: string
|
||||||
executablePath?: string
|
executablePath?: string
|
||||||
|
@ -139,6 +141,23 @@ 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 (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 {
|
} else {
|
||||||
await page.waitForSelector('#username')
|
await page.waitForSelector('#username')
|
||||||
await page.type('#username', email, { delay: 20 })
|
await page.type('#username', email, { delay: 20 })
|
||||||
|
@ -328,7 +347,6 @@ export async function getBrowser(
|
||||||
const page = (await browser.pages())[0] || (await browser.newPage())
|
const page = (await browser.pages())[0] || (await browser.newPage())
|
||||||
await page.goto(`https://nopecha.com/setup#${nopechaKey}`)
|
await page.goto(`https://nopecha.com/setup#${nopechaKey}`)
|
||||||
await delay(1000)
|
await delay(1000)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const page3 = await browser.newPage()
|
const page3 = await browser.newPage()
|
||||||
await page.close()
|
await page.close()
|
||||||
|
|
Ładowanie…
Reference in New Issue