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

Function getAllElements

Zhiyoo-Enhanced.user.js:459–476  ·  view source on GitHub ↗
(selector, contextNode = undefined, doc = document, win = window, _cplink = undefined)

Source from the content-addressed store, hash-verified

457 return result;
458 }
459 function getAllElements(selector, contextNode = undefined, doc = document, win = window, _cplink = undefined) {
460 if (!selector) return [];
461 contextNode = contextNode || doc;
462 if (typeof selector === 'string') {
463 if (selector.search(/^css;/i) === 0) {
464 return getAllElementsByCSS(selector.slice(4), contextNode);
465 } else {
466 return getAllElementsByXpath(selector, contextNode, doc);
467 }
468 } else {
469 const query = selector(doc, win, _cplink);
470 if (!Array.isArray(query)) {
471 throw new Error('getAllElements 返回错误类型');
472 } else {
473 return query;
474 }
475 }
476 }
477
478
479 // 获取GET参数

Callers 1

Calls 2

getAllElementsByCSSFunction · 0.70
getAllElementsByXpathFunction · 0.70

Tested by

no test coverage detected