Skip to content

Commit

Permalink
fix: re-pull latest anchor element after refreshing (#55)
Browse files Browse the repository at this point in the history
related #5
  • Loading branch information
JounQin authored Dec 14, 2023
1 parent 3f6d7bd commit e1f47ce
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/beige-points-decide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"dl-iconfont": patch
---

fix: re-pull latest anchor element after refreshing
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 e1f47ce

Please sign in to comment.