Skip to content

Instantly share code, notes, and snippets.

@iamandrewluca
Created February 12, 2024 20:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iamandrewluca/cc622b98a1661cfe860565f3988dd86b to your computer and use it in GitHub Desktop.
Save iamandrewluca/cc622b98a1661cfe860565f3988dd86b to your computer and use it in GitHub Desktop.
Remove Twitter

Get rid of all content from Twitter

How to use "Remove Tweets"

  1. Sign in to Twitter
  2. Go to your Profile
  3. Open DevTools and go to the 'Console' tab
  4. Copy and paste the following script
async function main() {
    let sleep = ms => new Promise(r => setTimeout(r, ms))

    while (true) {
        let tweet = document
            .querySelector(`[data-testid="tweet"] [data-testid="UserAvatar-Container-iamandrewluca"]`)
            ?.closest(`[data-testid="tweet"]`)

        if (!tweet) {
            window.scrollTo(0, document.body.scrollHeight || document.documentElement.scrollHeight);
            await sleep(2000);
            continue;
        };
        
        tweet.scrollIntoView();

        let more = tweet.querySelector(`[aria-label="More"]`)
        more.click();
        await sleep(500);

        document.querySelector('[data-testid="Dropdown"] > div').click()
        await sleep(500);

        document.querySelector('[data-testid="confirmationSheetConfirm"]').click()

        console.log('Done')
        await sleep(4000)
        
    }
    
}

main()

How to use "Unretweet"

  1. Sign in to Twitter
  2. Go to your Profile
  3. Open DevTools and go to the 'Console' tab
  4. Copy and paste the following script
async function main() {
    let sleep = ms => new Promise(r => setTimeout(r, ms))

    while (true) {
        let elem = document.querySelector('[data-testid="unretweet"]')
        
        if (!elem) {
            window.scrollTo(0, document.body.scrollHeight || document.documentElement.scrollHeight);
            await sleep(2000);
            continue;
        };
        
        elem.closest('[data-testid="tweet"]').scrollIntoView();

        elem.click()
        await sleep(500);
        
        document.querySelector('[data-testid="unretweetConfirm"]').click();
        console.log('Done');
        
        await sleep(500);
    }
    
}

main()

How to use "Unlike all Tweets"

  1. Sign in to Twitter
  2. Go to your Profile
  3. Go the Likes section
  4. Open DevTools and go to the 'Console' tab
  5. Copy and paste the following script
async function main() {
    let sleep = ms => new Promise(r => setTimeout(r, ms))

    while (true) {
        let heart = document.querySelector('[data-testid="unlike"]')
        if (!heart) return;
        heart.closest('[data-testid="tweet"]').scrollIntoView();
        heart.click();
        console.log('Unlike')
        await sleep(3000);
    }
    
}

main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment