Skip to content

Commit

Permalink
fix: re-pull latest anchor element after refreshing
Browse files Browse the repository at this point in the history
related #5
  • Loading branch information
JounQin committed Dec 14, 2023
1 parent 3f6d7bd commit 4c10fe4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,9 @@ export const fetchJsUrl = async ({
{ waitUntil: 'networkidle0' },
)

const anchor = await page.waitForSelector('a#J_cdn_type_svgsymbol')

const copy = await page.$('.project-code-top .cover-btn:not(:last-child)')
await page.waitForSelector('a#J_cdn_type_svgsymbol')

if (copy) {
if (await page.$('.project-code-top .cover-btn:not(:last-child)')) {
const refresh = await page.$('.project-code-top .cover-btn:last-child')
await refresh!.click()
const button = await page.waitForSelector(
Expand All @@ -76,6 +74,9 @@ export const fetchJsUrl = async ({
)
}

// re-pull latest anchor element after refreshing
const anchor = await page.waitForSelector('a#J_cdn_type_svgsymbol')

const jsUrl = await anchor!.evaluate(el => el.href)

await browser.close()
Expand Down

0 comments on commit 4c10fe4

Please sign in to comment.