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
619ddd91
Commit
619ddd91
authored
Dec 16, 2022
by
Travis Fischer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: improve chat page detection for browser version
parent
1af5db24
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
6 deletions
+19
-6
src/chatgpt-api-browser.ts
src/chatgpt-api-browser.ts
+19
-6
No files found.
src/chatgpt-api-browser.ts
View file @
619ddd91
...
@@ -8,10 +8,13 @@ import { getBrowser, getOpenAIAuth } from './openai-auth'
...
@@ -8,10 +8,13 @@ import { getBrowser, getOpenAIAuth } from './openai-auth'
import
{
import
{
browserPostEventStream
,
browserPostEventStream
,
isRelevantRequest
,
isRelevantRequest
,
markdownToText
,
maximizePage
,
maximizePage
,
minimizePage
minimizePage
}
from
'
./utils
'
}
from
'
./utils
'
const
CHAT_PAGE_URL
=
'
https://chat.openai.com/chat
'
export
class
ChatGPTAPIBrowser
extends
AChatGPTAPI
{
export
class
ChatGPTAPIBrowser
extends
AChatGPTAPI
{
protected
_markdown
:
boolean
protected
_markdown
:
boolean
protected
_debug
:
boolean
protected
_debug
:
boolean
...
@@ -134,11 +137,8 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
...
@@ -134,11 +137,8 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
throw
err
throw
err
}
}
const
chatUrl
=
'
https://chat.openai.com/chat
'
if
(
!
this
.
isChatPage
)
{
const
url
=
this
.
_page
.
url
().
replace
(
/
\/
$/
,
''
)
await
this
.
_page
.
goto
(
CHAT_PAGE_URL
,
{
if
(
url
!==
chatUrl
)
{
await
this
.
_page
.
goto
(
chatUrl
,
{
waitUntil
:
'
networkidle2
'
waitUntil
:
'
networkidle2
'
})
})
}
}
...
@@ -287,7 +287,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
...
@@ -287,7 +287,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
waitUntil
:
'
networkidle2
'
,
waitUntil
:
'
networkidle2
'
,
timeout
:
2
*
60
*
1000
// 2 minutes
timeout
:
2
*
60
*
1000
// 2 minutes
})
})
if
(
this
.
_minimize
)
{
if
(
this
.
_minimize
&&
this
.
isChatPage
)
{
await
minimizePage
(
this
.
_page
)
await
minimizePage
(
this
.
_page
)
}
}
console
.
log
(
`ChatGPT "
${
this
.
_email
}
" refreshed session successfully`
)
console
.
log
(
`ChatGPT "
${
this
.
_email
}
" refreshed session successfully`
)
...
@@ -451,6 +451,10 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
...
@@ -451,6 +451,10 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
throw
error
throw
error
}
else
{
}
else
{
if
(
!
this
.
_markdown
)
{
result
.
response
=
markdownToText
(
result
.
response
)
}
return
result
return
result
}
}
...
@@ -516,4 +520,13 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
...
@@ -516,4 +520,13 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
// [data-id="root"]
// [data-id="root"]
return
this
.
_page
.
$
(
'
textarea
'
)
return
this
.
_page
.
$
(
'
textarea
'
)
}
}
get
isChatPage
():
boolean
{
try
{
const
url
=
this
.
_page
?.
url
().
replace
(
/
\/
$/
,
''
)
return
url
===
CHAT_PAGE_URL
}
catch
(
err
)
{
return
false
}
}
}
}
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