Unlike all tweets bulk delete

Open the likes tab on your twitter profile and run this snippet of javascript.

function sleep(ms) {
  return new Promise(resolve => setTimeout(resolve, ms));
}

var locked = false;

async function unlike () {
    var divs = document.getElementsByTagName("div")
    var arr = Array.prototype.slice.call( divs)
    var hearts = arr.filter(x => x.getAttribute('data-testid') == 'unlike')
    var prevHeart = hearts[0];
    for (let h of hearts) {
        console.log("Unliked!")
        h.click();
        prevHeart.scrollIntoView();
        prevHeart = h;
        await sleep(2000 + Math.random());
    }
    locked = false;
}

var repeat = setInterval(async () => {
    if (!locked) {
        locked = true;
        await unlike();
        console.log("Scrolling for new tweets!");
        window.scrollTo(0, document.body.scrollHeight ||document.documentElement.scrollHeight);
    } else {
        console.log("Still running previous page unlikes!")
    }
}, 5000);

Mitesh Shah

Read more posts by this author.