Skip to content

Instantly share code, notes, and snippets.

@jasonmit
Last active July 10, 2018 04:22
Show Gist options
  • Save jasonmit/721ade2d980feff239c79fe8f3664376 to your computer and use it in GitHub Desktop.
Save jasonmit/721ade2d980feff239c79fe8f3664376 to your computer and use it in GitHub Desktop.
function timeout(ms) {
return new Promise((resolve) => {
setTimeout(() => resolve(), ms);
});
}
function blockCard(cardElement) {
const bio = cardElement.querySelector('.ProfileCard-bio');
const blockStatus = cardElement.querySelector('.blocked');
if (!bio|| blockStatus) {
return false;
}
const shouldBeBlocked = [
'deplorable',
'maga',
'walk away',
'walkaway',
'trump',
'2a',
'qanon',
'fake news',
'fakenews',
'genflynn',
'gen flynn',
'draintheswamp',
'drain the swamp',
'm.a.g.a',
'prolife',
'jesus',
'draintheswamp',
'americafirst',
'red pill',
'america first',
'build the wall',
'buildthewall',
'brexit',
'bluelivesmatter',
'blue lives matter',
'nra'
].some(word => bio.innerText && bio.innerText.toLowerCase().includes(word));
if (shouldBeBlocked) {
const block = cardElement.querySelector('.blockIcon');
block.click();
return true;
}
return false;
}
function onMutation(mutationsList) {
for (const mutation of mutationsList) {
if (mutation.type == 'childList') {
for (const group of mutation.addedNodes) {
if (group.children) {
for (const card of group.children) {
blockCard(card);
}
}
}
}
}
}
const observer = new MutationObserver(onMutation);
observer.observe(document.querySelector('.GridTimeline-items'), {
attributes: false,
childList: true,
subtree: true
});
async function tick() {
window.scrollTo(0, document.body.scrollHeight);
await timeout(1000);
await tick();
}
tick();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment