← Back to home

Auto-Confirm Unfollow Script for X (Twitter)

Skip the confirmation dialog when unfollowing people on X.com with this simple Tampermonkey script.

Tutorial

Auto-unfollow script demonstration

I don't claim responsibility for any effects of this script. Use at your own risk.

How to Install & Use

  1. Install Tampermonkey

    First, install the Tampermonkey browser extension:

    Install Tampermonkey for Chrome
  2. Allow User Scripts

    After installing Tampermonkey, make sure user scripts are enabled in the extension settings.

  3. Create New Script

    Click on the Tampermonkey icon in your browser and select "Create a new script". Then paste the script below:

    Userscript Code

    // ==UserScript== // @name Auto-Confirm Unfollow on X // @namespace http://tampermonkey.net/ // @version 1.0 // @description Automatically confirms unfollow actions on X.com to skip the dialog during manual unfollowing. // @author Beckett // @match https://x.com/* // @grant none // ==/UserScript== (function() { 'use strict'; // Use a MutationObserver to watch for changes in the DOM (e.g., when the confirmation dialog appears). const observer = new MutationObserver((mutations) => { console.log('observer'); for (const mutation of mutations) { for (const node of mutation.addedNodes) { if (node instanceof HTMLElement) { // Look for the confirmation button using its current data-testid attribute. const confirmButton = node.querySelector('[data-testid="confirmationSheetConfirm"]'); if (confirmButton) { console.log("confirm button identified"); confirmButton.click(); // Optional: You can add a short delay if needed, e.g., setTimeout(() => confirmButton.click(), 100); } } } } }); // Observe the entire document for added nodes (subtree for nested elements). observer.observe(document.body, { childList: true, subtree: true }); })();
  4. Enable the Script

    Save the script (Ctrl+S or Cmd+S) and make sure it's enabled in your Tampermonkey dashboard. The script will now automatically work on X.com.

  5. If it doesn't work

    Restart tampermonkey by going to > tampermonkey > dashboard > settings
    Set Config Mode to "advanced", scroll to bottom, click "restart tampermonkey".

Bonus script

Bonus script: Hide everyone who follows you back (Implementation is the same)

Bonus Userscript Code

// ==UserScript== // @name Hide Mutual Follows on X Following List // @namespace http://tampermonkey.net/ // @version 1.0 // @description Automatically hides users who follow you back ("Follows you") in your X.com following list to focus on one-way follows during a purge. // @author Beckett // @match https://x.com/* // @grant none // ==/UserScript== (function() { 'use strict'; console.log('Hide Mutual Follows Script Loaded'); // Confirm script injection // Function to check and hide a single user cell function hideMutualFollow(cell) { const followIndicator = cell.querySelector('[data-testid="userFollowIndicator"]'); if (followIndicator && followIndicator.textContent.trim() === 'Follows you') { cell.style.display = 'none'; console.log('Hid a mutual follow cell'); // For debugging } } // Initial scan for existing cells on page load document.querySelectorAll('[data-testid="cellInnerDiv"]').forEach(hideMutualFollow); // Use MutationObserver to watch for new cells added (e.g., as you scroll) const observer = new MutationObserver((mutations) => { console.log('Observer triggered by DOM change'); // For debugging mutations.forEach((mutation) => { mutation.addedNodes.forEach((node) => { if (node instanceof HTMLElement) { // Check if the added node is a user cell or contains one if (node.getAttribute('data-testid') === 'cellInnerDiv') { hideMutualFollow(node); } else { // Scan for nested user cells node.querySelectorAll('[data-testid="cellInnerDiv"]').forEach(hideMutualFollow); } } }); }); }); // Observe the body for changes (subtree for dynamic loads) observer.observe(document.body, { childList: true, subtree: true }); console.log('Observer initialized and watching for changes'); // Confirm setup })();