MCPcopy Create free account
hub / github.com/XIU2/UserScript / getAllElements

Function getAllElements

52pojie-Enhanced.user.js:378–395  ·  view source on GitHub ↗
(selector, contextNode = undefined, doc = document, win = window, _cplink = undefined)

Source from the content-addressed store, hash-verified

376 return result;
377 }
378 function getAllElements(selector, contextNode = undefined, doc = document, win = window, _cplink = undefined) {
379 if (!selector) return [];
380 contextNode = contextNode || doc;
381 if (typeof selector === 'string') {
382 if (selector.search(/^css;/i) === 0) {
383 return getAllElementsByCSS(selector.slice(4), contextNode);
384 } else {
385 return getAllElementsByXpath(selector, contextNode, doc);
386 }
387 } else {
388 const query = selector(doc, win, _cplink);
389 if (!Array.isArray(query)) {
390 throw new Error('getAllElements 返回错误类型');
391 } else {
392 return query;
393 }
394 }
395 }
396})();

Callers 1

showPagerFunction · 0.70

Calls 2

getAllElementsByCSSFunction · 0.70
getAllElementsByXpathFunction · 0.70

Tested by

no test coverage detected