Skip to content

Instantly share code, notes, and snippets.

@justinoboyle
Created June 18, 2017 23:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justinoboyle/7390e7a58f280ab0526d882a1060e976 to your computer and use it in GitHub Desktop.
Save justinoboyle/7390e7a58f280ab0526d882a1060e976 to your computer and use it in GitHub Desktop.
topD=document.getElementsByClassName('navigation-widget-content')[0];
l=allDescendants(topD, 0);
console.log(l);
copy(l);
console.log("copied to clipboard in markdown format :)");
function allDescendants (node, levels) {
let arr=[];
if(node.childNodes)
for (var i = 0; i < node.childNodes.length; i++) {
var child = node.childNodes[i];
for(let x of allDescendants(child, levels + 1)) arr.push(x);
if((child.className || "").toString().includes('level-')) {
len=parseInt((child.className || "").toString().split('level-')[1]);
arr.push(new Array((len) * 4).join(' ') + "* ", child.innerText + '\n');
}
}
return arr.join('');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment