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
ad20bb6f
Commit
ad20bb6f
authored
Dec 17, 2022
by
Travis Fischer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: make nopecha extension ID dynamic
parent
cbfaed93
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
20 deletions
+48
-20
src/openai-auth.ts
src/openai-auth.ts
+48
-20
No files found.
src/openai-auth.ts
View file @
ad20bb6f
...
...
@@ -269,26 +269,54 @@ export async function getBrowser(
const
page
=
(
await
browser
.
pages
())[
0
]
||
(
await
browser
.
newPage
())
await
page
.
goto
(
`https://nopecha.com/setup#
${
nopechaKey
}
`
)
await
delay
(
1000
)
const
page3
=
await
browser
.
newPage
()
await
page
.
close
()
const
extensionId
=
'
npgnhlnhpphdlkfdnggbdpbhoopefaai
'
const
extensionUrl
=
`chrome-extension://
${
extensionId
}
/popup.html`
await
page3
.
goto
(
extensionUrl
,
{
waitUntil
:
'
networkidle2
'
})
await
delay
(
500
)
const
editKey
=
await
page3
.
waitForSelector
(
'
#edit_key .clickable
'
)
await
editKey
.
click
()
const
settingsInput
=
await
page3
.
$
(
'
input.settings_text
'
)
await
settingsInput
.
type
(
nopechaKey
)
await
settingsInput
.
evaluate
((
el
,
value
)
=>
{
el
.
value
=
value
},
nopechaKey
)
await
settingsInput
.
press
(
'
Enter
'
)
await
delay
(
500
)
await
editKey
.
click
()
await
delay
(
2000
)
try
{
const
page3
=
await
browser
.
newPage
()
await
page
.
close
()
// find the nopecha extension ID
const
targets
=
browser
.
targets
()
const
extensionIds
=
(
await
Promise
.
all
(
targets
.
map
(
async
(
target
)
=>
{
if
(
target
.
type
()
!==
'
service_worker
'
)
{
return
}
// const titleL = title?.toLowerCase()
// if (titleL?.includes('nopecha'))
const
url
=
new
URL
(
target
.
url
())
return
url
.
hostname
})
)
).
filter
(
Boolean
)
const
extensionId
=
extensionIds
[
0
]
if
(
extensionId
)
{
const
extensionUrl
=
`chrome-extension://
${
extensionId
}
/popup.html`
await
page3
.
goto
(
extensionUrl
,
{
waitUntil
:
'
networkidle2
'
})
await
delay
(
500
)
const
editKey
=
await
page3
.
waitForSelector
(
'
#edit_key .clickable
'
)
await
editKey
.
click
()
const
settingsInput
=
await
page3
.
$
(
'
input.settings_text
'
)
await
settingsInput
.
type
(
nopechaKey
)
await
settingsInput
.
evaluate
((
el
,
value
)
=>
{
el
.
value
=
value
},
nopechaKey
)
await
settingsInput
.
press
(
'
Enter
'
)
await
delay
(
500
)
await
editKey
.
click
()
await
delay
(
2000
)
}
else
{
console
.
error
(
"
error initializing nopecha extension; couldn't determine extension ID
"
)
}
}
catch
(
err
)
{
console
.
error
(
'
error initializing nopecha extension
'
,
err
)
}
}
return
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