Block Twitter accounts promoting shit

Posted on January 26, 2019

I fucking hate advertising. It's why I have Firefox cranked up to block all tracking cookies, and it's why I use Pi-Hole to keep me even more protected from bullshit (to say nothing of speeding up my web browsing). To that end, I will usually just blindly block any account on Twitter that is promoting something, even if it's something I'm interested in. I know how to find things, I don't need a fucking advertisement.

I put together a little javascript that will block the first promoted tweet in your stream. Just paste this code into your console and run it. It'll simulate clicking on the little dropdown arrow, clicking the 'block @username', and clicking the 'block' button in the confirmation dialog.

document.querySelectorAll('.js-action-profile-promoted')
    .item(0)
    .parentNode
    .parentNode
    .parentNode
    .parentNode
    .querySelectorAll('.block-link')
    .item(0)
    .children
    .item(0)
    .click();
document.querySelectorAll('.block-dialog')
    .item(0)
    .querySelectorAll('.block-button')
    .item(0)
    .click();

If your browser supports it, you can drag this link into your toolbar and use it like a bookmarklet.

© 2019 Geoff Oliver · Powered by another stupid blog thing