Skip to content

Instantly share code, notes, and snippets.

@shariq
shariq / getArticleText.js
Last active Aug 18, 2020
getArticleText
View getArticleText.js
// fancily gets the text content of an html page
function getArticleText() {
function textNodesUnder(node){
var all = [];
for (node=node.firstChild;node;node=node.nextSibling){
if (node.nodeType==3) all.push(node);
else all = all.concat(textNodesUnder(node));
}
return all;