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
6733ade3
Commit
6733ade3
authored
Oct 31, 2023
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no more funcaptcha thanks
parent
8ee5750d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
18 deletions
+56
-18
build/index.js
build/index.js
+13
-12
build/index.js.map
build/index.js.map
+1
-1
src/chatgpt-api-browser.ts
src/chatgpt-api-browser.ts
+41
-5
src/utils.ts
src/utils.ts
+1
-0
No files found.
build/index.js
View file @
6733ade3
...
...
@@ -243,6 +243,7 @@ async function browserPostEventStream(url2, accessToken, body, timeoutMs) {
});
for
await
(
const
chunk
of
streamAsyncIterable2
(
res
.
body
))
{
const
str
=
new
TextDecoder
().
decode
(
chunk
);
console
.
log
(
`browserPostEventStream chunk:
${
str
}
`
);
parser
.
feed
(
str
);
}
}
...
...
@@ -785,7 +786,6 @@ var ChatGPTAPI = class extends AChatGPTAPI {
// src/chatgpt-api-browser.ts
import
delay2
from
"
delay
"
;
import
{
getToken
}
from
"
funcaptcha
"
;
import
{
temporaryDirectory
}
from
"
tempy
"
;
import
{
v4
as
uuidv42
}
from
"
uuid
"
;
...
...
@@ -1580,7 +1580,12 @@ var ChatGPTAPIBrowser = class extends AChatGPTAPI {
force_paragen
:
false
,
force_rate_limit
:
false
,
history_and_training_disabled
:
false
,
suggestions
:
[],
suggestions
:
[
"
0
"
,
"
1
"
,
"
2
"
,
"
3
"
],
timezone_offset_min
:
-
480
};
if
(
conversationId
)
{
...
...
@@ -1616,20 +1621,16 @@ var ChatGPTAPIBrowser = class extends AChatGPTAPI {
}
}
try
{
const
arkoseThing
=
await
getToken
({
pkey
:
"
3D86FBBA-9D22-402A-B512-3420086BA6CC
"
,
surl
:
"
https://tcr9i.chat.openai.com
"
,
headers
:
{
"
User-Agent
"
:
await
this
.
_page
.
browser
().
userAgent
()
},
site
:
"
https://chat.openai.com
"
,
proxy
:
this
.
_proxyServer
&&
(
this
.
_proxyServer
.
startsWith
(
"
http
"
)
?
this
.
_proxyServer
:
`http://
${
this
.
_proxyServer
}
`
)
});
const
reqProm
=
this
.
_page
.
waitForResponse
((
res
)
=>
res
.
url
()
===
"
https://tcr9i.chat.openai.com/fc/gt2/public_key/3D86FBBA-9D22-402A-B512-3420086BA6CC
"
,
{
timeout
:
1
e4
});
const
textarea
=
await
this
.
_page
.
waitForSelector
(
'
textarea[id="prompt-textarea"]
'
);
await
textarea
.
type
(
"
a
"
);
await
this
.
_page
.
keyboard
.
press
(
"
Backspace
"
);
const
req
=
await
reqProm
;
result
=
await
this
.
_page
.
evaluate
(
browserPostEventStream
,
url2
,
this
.
_accessToken
,
{
...
body
,
arkose_token
:
arkoseThing
.
token
},
{
...
body
,
arkose_token
:
(
await
req
.
json
())
.
token
},
timeoutMs
);
}
catch
(
err
)
{
...
...
build/index.js.map
View file @
6733ade3
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 @
6733ade3
import
delay
from
'
delay
'
import
{
getToken
}
from
'
funcaptcha
'
import
type
{
Browser
,
HTTPRequest
,
HTTPResponse
,
Page
}
from
'
puppeteer
'
import
{
temporaryDirectory
}
from
'
tempy
'
import
{
v4
as
uuidv4
}
from
'
uuid
'
...
...
@@ -478,7 +477,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
force_paragen
:
false
,
force_rate_limit
:
false
,
history_and_training_disabled
:
false
,
suggestions
:
[],
suggestions
:
[
'
0
'
,
'
1
'
,
'
2
'
,
'
3
'
],
timezone_offset_min
:
-
480
}
...
...
@@ -521,12 +520,16 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
}
}
// const ua = await this._page.browser().userAgent()
try
{
/*
const pkey = '3D86FBBA-9D22-402A-B512-3420086BA6CC'
const arkoseThing = await getToken({
pkey
:
'
3D86FBBA-9D22-402A-B512-3420086BA6CC
'
,
pkey,
surl: 'https://tcr9i.chat.openai.com',
headers: {
'
User-Agent
'
:
await
this
.
_page
.
browser
().
userAgent
()
'User-Agent':
ua
},
site: 'https://chat.openai.com',
proxy:
...
...
@@ -536,12 +539,45 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
: `http://${this._proxyServer}`)
})
const beforeUrlParams = new URLSearchParams({
callback: `__jsonp_${Date.now()}`,
category: 'loaded',
action: 'game loaded',
session_token: arkoseThing.token.split('|')[0],
'data[public_key]' : pkey,
'data[site]': 'https://chat.openai.com',
})
const beforeUrl = `https://tcr9i.chat.openai.com/fc/a/?${beforeUrlParams.toString()
.replaceAll('+', '%20')
.replaceAll('%5B', '[')
.replaceAll('%5D', ']')}`
await this._page.evaluate(async (beforeUrl) => {
await fetch(beforeUrl);
}, beforeUrl)
*/
const
reqProm
=
this
.
_page
.
waitForResponse
(
(
res
)
=>
res
.
url
()
===
'
https://tcr9i.chat.openai.com/fc/gt2/public_key/3D86FBBA-9D22-402A-B512-3420086BA6CC
'
,
{
timeout
:
10000
}
)
// get text area
const
textarea
=
await
this
.
_page
.
waitForSelector
(
'
textarea[id="prompt-textarea"]
'
)
// type in message and clear it
await
textarea
.
type
(
'
a
'
)
await
this
.
_page
.
keyboard
.
press
(
'
Backspace
'
)
const
req
=
await
reqProm
// console.log('>>> EVALUATE', url, this._accessToken, body)
result
=
await
this
.
_page
.
evaluate
(
browserPostEventStream
,
url
,
this
.
_accessToken
,
{
...
body
,
arkose_token
:
arkoseThing
.
token
},
{
...
body
,
arkose_token
:
(
await
req
.
json
())
.
token
},
timeoutMs
)
}
catch
(
err
)
{
...
...
src/utils.ts
View file @
6733ade3
...
...
@@ -228,6 +228,7 @@ export async function browserPostEventStream(
for
await
(
const
chunk
of
streamAsyncIterable
(
res
.
body
))
{
const
str
=
new
TextDecoder
().
decode
(
chunk
)
console
.
log
(
`browserPostEventStream chunk:
${
str
}
`
)
parser
.
feed
(
str
)
}
}
...
...
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