MCPcopy Create free account
hub / github.com/Useful-Scripts-Extension/useful-script / getAllChildElements

Function getAllChildElements

scripts/magnify_image.js:518–537  ·  view source on GitHub ↗
(element)

Source from the content-addressed store, hash-verified

516}
517
518function getAllChildElements(element) {
519 let childElements = [];
520
521 // Get all direct child elements of the current element
522 let children = element.children;
523 if (children?.length) {
524 childElements = childElements.concat(Array.from(children));
525
526 // Loop through each child element
527 for (let child of children) {
528 // Recursively call the function to get all descendants of the child element
529 let descendants = getAllChildElements(child);
530
531 // Add the descendants to the array
532 childElements = childElements.concat(descendants);
533 }
534 }
535
536 return childElements;
537}
538
539function getAllParentElements(element) {
540 let parentElements = [];

Callers 1

getImagesAtPosFunction · 0.85

Calls 1

concatMethod · 0.80

Tested by

no test coverage detected