Skip to content

Instantly share code, notes, and snippets.

@kubarium
Last active April 20, 2018 02:38
Show Gist options
  • Save kubarium/6be6efbefcf379a0be5cd3a4ba4c3c5e to your computer and use it in GitHub Desktop.
Save kubarium/6be6efbefcf379a0be5cd3a4ba4c3c5e to your computer and use it in GitHub Desktop.
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