Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Based on, this is (will be) a script to fetch text nodes from the current page, pick a few random phrases, and combine them into an entertaining song name with band, track, and optionally remixer/remix name.
function findTextNodes( node ) {
var text = [];
if ( node.nodeType === 3 ) {
text.push( node.nodeValue );
// TODO: Filter out carriage returns, whitespace.
// POSSIBLE TODO: Restrict to nodes within the main content area of the page? (so don't get ads, etc)
} else {
for ( var i = 0, max = node.childNodes.length; i < max; i++ ) {
text = text.concat( findTextNodes( node.childNodes[i] ) );
return text;
var textNodes = findTextNodes( document.body );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment