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

Function getAllElements

3dm-Enhanced.user.js:393–410  ·  view source on GitHub ↗
(selector, contextNode = undefined, doc = document, win = window, _cplink = undefined)

Source from the content-addressed store, hash-verified

391 return result;
392 }
393 function getAllElements(selector, contextNode = undefined, doc = document, win = window, _cplink = undefined) {
394 if (!selector) return [];
395 contextNode = contextNode || doc;
396 if (typeof selector === 'string') {
397 if (selector.search(/^css;/i) === 0) {
398 return getAllElementsByCSS(selector.slice(4), contextNode);
399 } else {
400 return getAllElementsByXpath(selector, contextNode, doc);
401 }
402 } else {
403 const query = selector(doc, win, _cplink);
404 if (!Array.isArray(query)) {
405 throw new Error('getAllElements 返回错误类型');
406 } else {
407 return query;
408 }
409 }
410 }
411})();

Callers 1

Calls 2

getAllElementsByCSSFunction · 0.70
getAllElementsByXpathFunction · 0.70

Tested by

no test coverage detected