Skip to content

Instantly share code, notes, and snippets.

@fdebijl
Created February 14, 2019 15:03
Show Gist options
  • Save fdebijl/965e051f47002de1998d49ae34d4eb58 to your computer and use it in GitHub Desktop.
Save fdebijl/965e051f47002de1998d49ae34d4eb58 to your computer and use it in GitHub Desktop.
6Cijfers
// ==UserScript==
// @name Accounts met zes cijfers zijn altijd nazi's
// @namespace https://floris.debijl.xyz/
// @version 1.0
// @description Laat geen tweets zien van gebruikers die zes cijfers of meer in hun naam hebben
// @author Fdebijl
// @match https://tweetdeck.twitter.com/
// @match https://twitter.com/*
// @grant none
// ==/UserScript==
(() => {
'use strict';
// De tijd in seconden tussen het checken voor geblokkeerde quotetweets (Getal)
let INTERVAL = 30;
// Alles hierna hoef je niet aan te passen
const DECK_SELECTOR = {
USERNAME: '.account-inline > .username',
TWEETROOT: 'stream-item'
}
const WEB_SELECTOR = {
USERNAME: '.content .account-group > .username > b',
TWEETROOT: 'stream-item'
}
const SELECTOR = getSelector();
if (!SELECTOR) {
return;
}
function findAndDelete() {
let deleted = 0;
let users = [...document.querySelectorAll(SELECTOR.USERNAME)].filter(element => {
return element.innerText.match(/[0-9]{6,}/gi);
});
for(let i = 0; i < users.length; i++) {
let parent = users[i].parentElement;
while (!parent.classList.contains(SELECTOR.TWEETROOT)) {
parent = parent.parentElement;
}
parent.style.display = 'none';
deleted++;
}
console.log(`Deleted ${deleted} tweets.`);
}
function getSelector() {
switch (window.location.hostname) {
case 'tweetdeck.twitter.com':
return DECK_SELECTOR;
break;
case 'twitter.com':
return WEB_SELECTOR;
break;
default:
return false;
break;
}
}
setInterval(findAndDelete, INTERVAL * 1000);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment