Skip to content

Commit

Permalink
feat: improve nopecha key input
Browse files Browse the repository at this point in the history
  • Loading branch information
transitive-bullshit committed Dec 24, 2022
1 parent 814976c commit 97f9c80
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
30 changes: 15 additions & 15 deletions src/openai-auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,12 +389,6 @@ export async function initializeNopechaExtension(
await page.goto(`https://nopecha.com/setup#${nopechaKey}`)
await delay(1000)
try {
const page3 = await browser.newPage()
if (minimize) {
await minimizePage(page3)
}

await page.close()
// find the nopecha extension ID
const targets = browser.targets()
const extensionIds = (
Expand All @@ -417,19 +411,25 @@ export async function initializeNopechaExtension(

if (extensionId) {
const extensionUrl = `chrome-extension://${extensionId}/popup.html`
await page3.goto(extensionUrl, { waitUntil: 'networkidle2' })
const editKey = await page3.waitForSelector('#edit_key .clickable')
await page.goto(extensionUrl, { waitUntil: 'networkidle2' })
const editKey = await page.waitForSelector('#edit_key .clickable')
await editKey.click()
await delay(100)

for (let i = 0; i <= 30; i++) {
await editKey.press('Backspace')
const settingsInput = await page.waitForSelector('input.settings_text')
const value = await settingsInput.evaluate((el) => el.value)

if (value !== nopechaKey) {
for (let i = 0; i <= 30; i++) {
await settingsInput.press('Backspace')
}

await settingsInput.type(nopechaKey)
await settingsInput.press('Enter')
await delay(500)
await editKey.click()
await delay(2000)
}

await editKey.type(nopechaKey)
await delay(500)
await editKey.press('Enter')
await delay(2500)
console.log('initialized nopecha extension with key', nopechaKey)
} else {
console.error(
Expand Down

This file was deleted.

0 comments on commit 97f9c80

Please sign in to comment.