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
97fef500
Commit
97fef500
authored
Mar 20, 2024
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updates
parent
e3a96b68
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
26 deletions
+20
-26
build/index.js
build/index.js
+7
-10
build/index.js.map
build/index.js.map
+1
-1
src/chatgpt-api-browser.ts
src/chatgpt-api-browser.ts
+2
-2
src/fetch-sse.ts
src/fetch-sse.ts
+1
-1
src/openai-auth.ts
src/openai-auth.ts
+9
-12
No files found.
build/index.js
View file @
97fef500
...
...
@@ -47,7 +47,7 @@ async function fetchSSE(url2, options) {
const
{
onMessage
,
...
fetchOptions
}
=
options
;
const
res
=
await
fetch2
(
url2
,
fetchOptions
);
if
(
!
res
.
ok
)
{
const
msg
=
`ChatGPTAPI error
${
res
.
status
||
res
.
statusText
}
`
;
const
msg
=
`ChatGPTAPI error
${
res
.
status
||
res
.
statusText
}
${
res
.
json
()}
`
;
const
error
=
new
ChatGPTError
(
msg
);
error
.
statusCode
=
res
.
status
;
error
.
statusText
=
res
.
statusText
;
...
...
@@ -906,8 +906,8 @@ async function getOpenAIAuth({
]);
await
delay
(
1
e3
);
}
else
{
await
page
.
waitForSelector
(
"
#
username
"
);
await
page
.
type
(
"
#
username
"
,
email
);
await
page
.
waitForSelector
(
"
#
email-input
"
);
await
page
.
type
(
"
#
email-input
"
,
email
);
await
delay
(
100
);
if
(
!
hasRecaptchaPlugin
)
{
await
waitForRecaptcha
(
page
,
{
timeoutMs
});
...
...
@@ -931,20 +931,19 @@ async function getOpenAIAuth({
}
await
delay
(
2
e3
);
const
frame
=
page
.
mainFrame
();
const
continueSelector
=
"
.continue-btn
"
;
const
submit
=
await
page
.
waitForSelector
(
'
button[type="submit"][data-action-button-primary="true"]
'
,
continueSelector
,
{
timeout
:
timeoutMs
}
);
await
frame
.
focus
(
'
button[type="submit"][data-action-button-primary="true"]
'
);
await
frame
.
focus
(
continueSelector
);
await
submit
.
focus
();
await
submit
.
click
();
await
page
.
waitForSelector
(
"
#password
"
,
{
timeout
:
timeoutMs
});
await
page
.
type
(
"
#password
"
,
password
);
await
delay
(
1
e4
);
await
delay
(
5
e3
);
submitP
=
async
()
=>
{
await
page
.
click
(
'
button[type="submit"][data-action-button-primary="true"]
'
...
...
@@ -1651,10 +1650,8 @@ var ChatGPTAPIBrowser = class extends AChatGPTAPI {
}
else
if
(
error
.
statusCode
!==
403
)
{
throw
error
;
}
else
if
(
numTries
>=
2
)
{
await
this
.
refreshSession
();
throw
error
;
}
else
{
await
this
.
refreshSession
();
await
delay2
(
1
e3
);
result
=
null
;
continue
;
...
...
build/index.js.map
View file @
97fef500
This source diff could not be displayed because it is too large. You can
view the blob
instead.
src/chatgpt-api-browser.ts
View file @
97fef500
...
...
@@ -621,10 +621,10 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
}
else
if
(
error
.
statusCode
!==
403
)
{
throw
error
}
else
if
(
numTries
>=
2
)
{
await
this
.
refreshSession
()
//
await this.refreshSession()
throw
error
}
else
{
await
this
.
refreshSession
()
//
await this.refreshSession()
await
delay
(
1000
)
result
=
null
continue
...
...
src/fetch-sse.ts
View file @
97fef500
...
...
@@ -11,7 +11,7 @@ export async function fetchSSE(
const
{
onMessage
,
...
fetchOptions
}
=
options
const
res
=
await
fetch
(
url
,
fetchOptions
)
if
(
!
res
.
ok
)
{
const
msg
=
`ChatGPTAPI error
${
res
.
status
||
res
.
statusText
}
`
const
msg
=
`ChatGPTAPI error
${
res
.
status
||
res
.
statusText
}
${
res
.
json
()}
`
const
error
=
new
types
.
ChatGPTError
(
msg
)
error
.
statusCode
=
res
.
status
error
.
statusText
=
res
.
statusText
...
...
src/openai-auth.ts
View file @
97fef500
...
...
@@ -176,8 +176,8 @@ export async function getOpenAIAuth({
])
await
delay
(
1000
)
}
else
{
await
page
.
waitForSelector
(
'
#
username
'
)
await
page
.
type
(
'
#
username
'
,
email
)
await
page
.
waitForSelector
(
'
#
email-input
'
)
await
page
.
type
(
'
#
email-input
'
,
email
)
await
delay
(
100
)
// NOTE: this is where you may encounter a CAPTCHA
...
...
@@ -206,20 +206,17 @@ export async function getOpenAIAuth({
await
delay
(
2000
)
const
frame
=
page
.
mainFrame
()
const
submit
=
await
page
.
waitForSelector
(
'
button[type="submit"][data-action-button-primary="true"]
'
,
{
timeout
:
timeoutMs
}
)
await
frame
.
focus
(
'
button[type="submit"][data-action-button-primary="true"]
'
)
// a button, with class continue-btn
const
continueSelector
=
'
.continue-btn
'
const
submit
=
await
page
.
waitForSelector
(
continueSelector
,
{
timeout
:
timeoutMs
})
await
frame
.
focus
(
continueSelector
)
await
submit
.
focus
()
await
submit
.
click
()
await
page
.
waitForSelector
(
'
#password
'
,
{
timeout
:
timeoutMs
})
await
page
.
type
(
'
#password
'
,
password
)
await
delay
(
10
000
)
await
delay
(
5
000
)
submitP
=
async
()
=>
{
//console.log('1st click')
await
page
.
click
(
...
...
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