Skip to content

Instantly share code, notes, and snippets.

@shariq
shariq / getArticleText.js
Last active August 18, 2020 00:44
getArticleText
// 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;