Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
Chatgpt Puppeteer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
Chatgpt Puppeteer
Commits
7222b7f2
Commit
7222b7f2
authored
Dec 18, 2022
by
Travis Fischer
Committed by
GitHub
Dec 18, 2022
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #167 from optionsx/Addition_Microsoft_Login
parents
b8d1f595
65b94a36
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
3 deletions
+28
-3
src/chatgpt-api-browser.ts
src/chatgpt-api-browser.ts
+9
-2
src/openai-auth.ts
src/openai-auth.ts
+19
-1
No files found.
src/chatgpt-api-browser.ts
View file @
7222b7f2
...
@@ -20,6 +20,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
...
@@ -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 {
...
@@ -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 {
...
@@ -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 {
...
@@ -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 {
...
@@ -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 {
...
@@ -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
'
})
})
...
...
src/openai-auth.ts
View file @
7222b7f2
...
@@ -53,6 +53,7 @@ export async function getOpenAIAuth({
...
@@ -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({
...
@@ -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({
...
@@ -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(
...
@@ -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
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment