Skip to content

Instantly share code, notes, and snippets.

@ToreJuloe
Last active August 13, 2019 12:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ToreJuloe/7faad1a25fe321b4087cb65087c37970 to your computer and use it in GitHub Desktop.
Save ToreJuloe/7faad1a25fe321b4087cb65087c37970 to your computer and use it in GitHub Desktop.
Remove click-bait on BT
(function() {
const setContent = element => nodesArray => {
element.innerText = "";
nodesArray.forEach(node => {
element.appendChild(node);
});
};
const parseHTML = text => new DOMParser().parseFromString(text, "text/html");
const getElements = selectorArray => doc =>
selectorArray.map(el => doc.querySelector(el));
document.querySelectorAll(".dre-item__title").forEach(el =>
fetch(el.href)
.then(response => response.text())
.then(parseHTML)
.then(
getElements(["h1.article-title", ".article-content>p:first-of-type"])
)
.then(setContent(el)));
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment