@cloud411716/fancy-webnovel 0.3.8 → 0.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloud411716/fancy-webnovel",
3
- "version": "0.3.8",
3
+ "version": "0.3.9",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "exports": {
@@ -67,6 +67,18 @@ async function extractCategories(page, channel, type) {
67
67
 
68
68
  /** 从 __INITIAL_STATE__ 提取当前品类页的作品列表 */
69
69
  async function extractBookList(page) {
70
+ // 等 __INITIAL_STATE__ 有书单数据后再提取(防止网络慢时页面 JS 还没注数据)
71
+ await page.waitForFunction(
72
+ () => {
73
+ const s = window.__INITIAL_STATE__ || {};
74
+ const cands = [s.rank, s.rankData, s.page];
75
+ for (const c of cands) {
76
+ if (c && (c.book_list || c.bookList || c.rankList)) return true;
77
+ }
78
+ return false;
79
+ },
80
+ { timeout: 15000 }
81
+ );
70
82
  return page.evaluate(() => {
71
83
  const s = window.__INITIAL_STATE__ || {};
72
84
  const cands = [