MCPcopy Create free account
hub / github.com/DIYgod/RSSHub / forEachScript

Function forEachScript

lib/utils/wechat-mp.ts:95–111  ·  view source on GitHub ↗
($: CheerioAPI | string, callback: (script) => void, defaultReturn: any = null, selector = 'script[nonce][type="text/javascript"]')

Source from the content-addressed store, hash-verified

93}
94
95const forEachScript = ($: CheerioAPI | string, callback: (script) => void, defaultReturn: any = null, selector = 'script[nonce][type="text/javascript"]') => {
96 const scripts = typeof $ === 'string' ? [$] : $(selector).toArray();
97 for (const script of scripts) {
98 try {
99 callback(script);
100 } catch (error) {
101 if (error instanceof LoopReturn) {
102 return error.to_return;
103 }
104 if (error instanceof LoopContinue) {
105 continue;
106 }
107 throw error;
108 }
109 }
110 return defaultReturn;
111};
112
113// view-source a *_SHARE_PAGE type article and search for `ITEM_SHOW_TYPE_MAP`
114// Please update the comments below if you find new types or new examples

Callers 1

ExtractMetadataClass · 0.85

Calls 1

$Function · 0.85

Tested by

no test coverage detected