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
fa29f3da
Commit
fa29f3da
authored
Dec 21, 2022
by
timordnung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Proxy Auth
parent
318a03be
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
131 deletions
+2
-131
.env.example
.env.example
+2
-2
src/openai-auth.ts
src/openai-auth.ts
+0
-129
No files found.
.env.example
View file @
fa29f3da
...
...
@@ -9,5 +9,5 @@
# ChatGPT
# -----------------------------------------------------------------------------
OPENAI_EMAIL=
OPENAI_PASSWORD=
OPENAI_EMAIL=
"addresse5@cubemail.club"
OPENAI_PASSWORD=
"AddressePassword"
src/openai-auth.ts
View file @
fa29f3da
...
...
@@ -240,135 +240,6 @@ export async function getOpenAIAuth({
}
}
export
async
function
signUp
({
email
,
password
,
browser
,
page
,
timeoutMs
=
2
*
60
*
1000
,
isGoogleLogin
=
false
,
captchaToken
=
process
.
env
.
CAPTCHA_TOKEN
}:
{
email
?:
string
password
?:
string
browser
?:
Browser
page
?:
Page
timeoutMs
?:
number
isGoogleLogin
?:
boolean
captchaToken
?:
string
}):
Promise
<
boolean
>
{
const
origBrowser
=
browser
const
origPage
=
page
try
{
if
(
!
browser
)
{
browser
=
await
getBrowser
({
captchaToken
})
}
const
userAgent
=
await
browser
.
userAgent
()
if
(
!
page
)
{
page
=
(
await
browser
.
pages
())[
0
]
||
(
await
browser
.
newPage
())
page
.
setDefaultTimeout
(
timeoutMs
)
}
await
page
.
goto
(
'
https://chat.openai.com/auth/login
'
,
{
waitUntil
:
'
networkidle2
'
})
// NOTE: this is where you may encounter a CAPTCHA
if
(
hasRecaptchaPlugin
)
{
await
page
.
solveRecaptchas
()
}
await
checkForChatGPTAtCapacity
(
page
)
// once we get to this point, the Cloudflare cookies should be available
// login as well (optional)
if
(
email
&&
password
)
{
await
waitForConditionOrAtCapacity
(
page
,
()
=>
page
.
waitForSelector
(
'
#__next > div > div > div.flex.flex-row.gap-3 > button:nth-child(2)
'
,
{
timeout
:
timeoutMs
}
)
)
await
delay
(
500
)
// click login button and wait for navigation to finish
await
Promise
.
all
([
page
.
waitForNavigation
({
waitUntil
:
'
networkidle2
'
,
timeout
:
timeoutMs
}),
page
.
click
(
'
#__next > div > div > div.flex.flex-row.gap-3 > button:nth-child(2)
'
)
])
await
checkForChatGPTAtCapacity
(
page
)
let
submitP
:
()
=>
Promise
<
void
>
if
(
isGoogleLogin
)
{
await
page
.
click
(
'
button[data-provider="google"]
'
)
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
page
.
waitForSelector
(
'
input[type="password"]
'
,
{
visible
:
true
})
await
page
.
type
(
'
input[type="password"]
'
,
password
,
{
delay
:
10
})
submitP
=
()
=>
page
.
keyboard
.
press
(
'
Enter
'
)
}
else
{
await
page
.
waitForSelector
(
'
#email
'
)
await
page
.
type
(
'
#email
'
,
email
,
{
delay
:
20
})
await
delay
(
100
)
if
(
hasRecaptchaPlugin
)
{
console
.
log
(
'
solveRecaptchas()
'
)
const
res
=
await
page
.
solveRecaptchas
()
// console.log('solveRecaptchas result', res)
}
await
page
.
click
(
'
button[type="submit"]
'
)
await
page
.
waitForSelector
(
'
#password
'
,
{
timeout
:
timeoutMs
})
await
page
.
type
(
'
#password
'
,
password
,
{
delay
:
10
})
submitP
=
()
=>
page
.
click
(
'
button[type="submit"]
'
)
}
await
Promise
.
all
([
waitForConditionOrAtCapacity
(
page
,
()
=>
page
.
waitForNavigation
({
waitUntil
:
'
networkidle2
'
,
timeout
:
timeoutMs
})
),
submitP
()
])
}
else
{
await
delay
(
2000
)
await
checkForChatGPTAtCapacity
(
page
)
}
return
true
}
catch
(
err
)
{
throw
err
}
finally
{
if
(
origBrowser
)
{
if
(
page
&&
page
!==
origPage
)
{
await
page
.
close
()
}
}
else
if
(
browser
)
{
await
browser
.
close
()
}
page
=
null
browser
=
null
}
}
/**
* Launches a non-puppeteer instance of Chrome. Note that in my testing, I wasn't
* able to use the built-in `puppeteer` version of Chromium because Cloudflare
...
...
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