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
e21a690e
Commit
e21a690e
authored
Jan 19, 2023
by
Lawrence Onah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: add support for userDataDir
parent
b5698e3a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
2 deletions
+12
-2
package.json
package.json
+1
-0
src/chatgpt-api-browser.ts
src/chatgpt-api-browser.ts
+11
-2
No files found.
package.json
View file @
e21a690e
...
@@ -47,6 +47,7 @@
...
@@ -47,6 +47,7 @@
"
random
"
:
"
^4.1.0
"
,
"
random
"
:
"
^4.1.0
"
,
"
remark
"
:
"
^14.0.2
"
,
"
remark
"
:
"
^14.0.2
"
,
"
strip-markdown
"
:
"
^5.0.0
"
,
"
strip-markdown
"
:
"
^5.0.0
"
,
"
tempy
"
:
"
^3.0.0
"
,
"
uuid
"
:
"
^9.0.0
"
"
uuid
"
:
"
^9.0.0
"
},
},
"devDependencies"
:
{
"devDependencies"
:
{
...
...
src/chatgpt-api-browser.ts
View file @
e21a690e
import
delay
from
'
delay
'
import
delay
from
'
delay
'
import
type
{
Browser
,
HTTPRequest
,
HTTPResponse
,
Page
}
from
'
puppeteer
'
import
type
{
Browser
,
HTTPRequest
,
HTTPResponse
,
Page
}
from
'
puppeteer
'
import
{
temporaryDirectory
}
from
'
tempy
'
import
{
v4
as
uuidv4
}
from
'
uuid
'
import
{
v4
as
uuidv4
}
from
'
uuid
'
import
*
as
types
from
'
./types
'
import
*
as
types
from
'
./types
'
...
@@ -37,6 +38,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
...
@@ -37,6 +38,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
string
,
string
,
(
partialResponse
:
types
.
ChatResponse
)
=>
void
(
partialResponse
:
types
.
ChatResponse
)
=>
void
>
>
protected
_userDataDir
:
string
/**
/**
* Creates a new client for automating the ChatGPT webapp.
* Creates a new client for automating the ChatGPT webapp.
...
@@ -71,6 +73,9 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
...
@@ -71,6 +73,9 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
/** @defaultValue `undefined` **/
/** @defaultValue `undefined` **/
proxyServer
?:
string
proxyServer
?:
string
/** @defaultValue `random directory with email as prefix` **/
userDataDir
?:
string
})
{
})
{
super
()
super
()
...
@@ -85,7 +90,8 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
...
@@ -85,7 +90,8 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
captchaToken
,
captchaToken
,
nopechaKey
,
nopechaKey
,
executablePath
,
executablePath
,
proxyServer
proxyServer
,
userDataDir
}
=
opts
}
=
opts
this
.
_email
=
email
this
.
_email
=
email
...
@@ -102,6 +108,8 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
...
@@ -102,6 +108,8 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
this
.
_proxyServer
=
proxyServer
this
.
_proxyServer
=
proxyServer
this
.
_isRefreshing
=
false
this
.
_isRefreshing
=
false
this
.
_messageOnProgressHandlers
=
{}
this
.
_messageOnProgressHandlers
=
{}
this
.
_userDataDir
=
userDataDir
??
temporaryDirectory
({
prefix
:
this
.
_email
})
if
(
!
this
.
_email
)
{
if
(
!
this
.
_email
)
{
const
error
=
new
types
.
ChatGPTError
(
'
ChatGPT invalid email
'
)
const
error
=
new
types
.
ChatGPTError
(
'
ChatGPT invalid email
'
)
...
@@ -127,7 +135,8 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
...
@@ -127,7 +135,8 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
nopechaKey
:
this
.
_nopechaKey
,
nopechaKey
:
this
.
_nopechaKey
,
executablePath
:
this
.
_executablePath
,
executablePath
:
this
.
_executablePath
,
proxyServer
:
this
.
_proxyServer
,
proxyServer
:
this
.
_proxyServer
,
minimize
:
this
.
_minimize
minimize
:
this
.
_minimize
,
userDataDir
:
this
.
_userDataDir
})
})
this
.
_page
=
await
getPage
(
this
.
_browser
,
{
this
.
_page
=
await
getPage
(
this
.
_browser
,
{
...
...
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