diff --git a/.changeset/beige-points-decide.md b/.changeset/beige-points-decide.md new file mode 100644 index 00000000..1335875f --- /dev/null +++ b/.changeset/beige-points-decide.md @@ -0,0 +1,5 @@ +--- +"dl-iconfont": patch +--- + +fix: re-pull latest anchor element after refreshing diff --git a/src/index.ts b/src/index.ts index 44cedc6c..81ffdf41 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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( @@ -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()