Skip to content

Instantly share code, notes, and snippets.

@rdadrl
Created May 14, 2020 14:30
Show Gist options
  • Save rdadrl/176ee73c3d12527ab755aca8ffb586d8 to your computer and use it in GitHub Desktop.
Save rdadrl/176ee73c3d12527ab755aca8ffb586d8 to your computer and use it in GitHub Desktop.
Filter Tweets in your feed by emojis in user display names.
//A small gist to filter out unwanted tweets
//Categorizes by the emojis used in the display names
//param labelList: an array of strings corresponding to emoji names (e.g. ["Green circle", "🏠"])
function filterArticleList (labelList) {
articles = document.getElementsByTagName("article")
for (i = 0; i < articles.length; i++) {
displayNameHRef = articles[i].getElementsByTagName("a")[1];
sects = displayNameHRef.getElementsByTagName("div");
labelsToMatch = [...labelList];
for (j = 0; j < sects.length; j++) {
for (k = 0; k < labelsToMatch.length; k++) {
if (sects[j].ariaLabel == labelsToMatch[k]) {
labelsToMatch.splice(k, 1); //remove entry as it's found
k--; //k decreases to make up for removed entry.
}
}
if (labelsToMatch.length == 0) break;
}
if (labelsToMatch.length == 0) { //particular account fits the filter
console.log("Removing unwanted content [" + i + "], tweeted by: " + displayNameHRef.text);
articles[i].remove();
}
}
}
//This is optional- set the interval duration to your own needs.
__filterTimeout = setInterval(filterArticleList, 1000, ["🏠"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment