Skip to content

Instantly share code, notes, and snippets.

@goyuix
Last active September 6, 2021 22:21
Show Gist options
  • Save goyuix/eecda9ab579de577531b460b870744f4 to your computer and use it in GitHub Desktop.
Save goyuix/eecda9ab579de577531b460b870744f4 to your computer and use it in GitHub Desktop.
Helpful JavaScript
// remove unwanted titles from list of articles
var articles = document.querySelectorAll("article h1 a");
var filters = [/American Horror Story/i,/Naked News/i,/ReidOut With Joy Reid/i,/Real Housewives/i,/Ancient Aliens/i,/Love Island/i,/Love After Lockup/i,/Lawrence O Donnell/i,/Hannity/i,/Ingraham Angle/i,/Tucker Carlson/i,/^WWE /i,/Bill Maher/i,/^Dateline /i,/Brian Williams/i,/Jimmy Kimmel/i,/Rachel Maddow/i,/Seth Meyers/i,/Desus and Mero/i]
articles.forEach(a => { filters.forEach(f => { if (f.test(a.innerText)){a.closest("article").remove();}})})
// remove matching articles by clicking calendar icon in header (by year || season/episode
document.addEventListener("click", function(ev){
var el=ev.target.closest(".entry-header");
if(el){
var a=el.querySelector(".entry-title a");
var text=a.innerText;
var season=(/S[0-9]{2}E[0-9]{2}/i).exec(text);
var year=(/[0-9]{4}/).exec(text);
if((year && year.length>0)||(season && season.length>0)){
var title=new RegExp("^"+text.substring(0,(year||season).index));
document.querySelectorAll(".entry-title a").forEach(entry => {
if(title.test(entry.innerText)){
entry.closest(".post-wrapper-hentry").remove()
}
});
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment