Skip to content

Instantly share code, notes, and snippets.

@kubarium
Last active April 20, 2018 02:38
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Goodreads Book Title, Author Name Extractor: http://denizkumsal.com/programming/trifecta-filter-map-reduce/
console.log(
Array.from(document.querySelectorAll(".bookTitle, .authorName"))
.filter((entry) => entry.attributes.itemprop)
.map((entry) => entry.innerText.replace(/\s\(.*?\)\s?/, ""))
.reduce(
(result, entry, index, list) =>
index % 2 == 0 ? result.concat(`${list[index]}, ${list[index + 1]}`) : result,
[]
)
.join("\n")
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment