Skip to content

Instantly share code, notes, and snippets.

@0x3n0
Last active December 29, 2024 15:30
Show Gist options
  • Select an option

  • Save 0x3n0/8db956cce800a741a76cd7a53b808999 to your computer and use it in GitHub Desktop.

Select an option

Save 0x3n0/8db956cce800a741a76cd7a53b808999 to your computer and use it in GitHub Desktop.
(async function () {
    const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
    const clickMuteButton = async () => {
        const replies = document.querySelectorAll('[data-testid="tweet"]');
        for (const reply of replies) {
            const blueCheck = reply.querySelector('svg[aria-label="Verified account"]');
            if (blueCheck) {
                const moreOptionsButton = reply.querySelector('[aria-label="More"]');
                if (moreOptionsButton) {
                    moreOptionsButton.click();
                    await delay(500);
                    const muteButton = Array.from(document.querySelectorAll('[role="menuitem"]'))
                        .find(item => item.textContent.includes('Mute'));
                    if (muteButton) {
                        muteButton.click();
                        console.log("Muted an account with a blue checkmark!");
                        await delay(1000);
                    }
                }
            }
        }
    };

    console.log("Scanning for blue check accounts to mute...");
    await clickMuteButton();
    console.log("Done!");
})();

Auto Scroll

(async function () {
    const delay = ms => new Promise(resolve => setTimeout(resolve, ms));

    async function scrollToLoadMore() {
        console.log("Scrolling to load more replies...");
        window.scrollTo(0, document.body.scrollHeight); // Scroll ke bawah
        await delay(2000);
    }

    async function clickMuteButton() {
        let accountsMuted = 0;
        const replies = document.querySelectorAll('[data-testid="tweet"]');

        for (const reply of replies) {
            const blueCheck = reply.querySelector('svg[aria-label="Verified account"]');
            if (blueCheck) {
                const moreOptionsButton = reply.querySelector('[aria-label="More"]');
                if (moreOptionsButton) {
                    moreOptionsButton.click();
                    await delay(500);

                    const muteButton = Array.from(document.querySelectorAll('[role="menuitem"]'))
                        .find(item => item.textContent.includes('Mute'));
                    if (muteButton) {
                        muteButton.click();
                        console.log("Muted an account with a blue checkmark!");
                        accountsMuted++;
                        await delay(1000);
                    }
                }
            }
        }
        return accountsMuted;
    }

    async function processRepliesUntilDone() {
        let totalMuted = 0;
        let retries = 0;

        while (retries < 10) {
            console.log(`Scanning... Attempt ${retries + 1}`);
            const accountsMuted = await clickMuteButton();
            totalMuted += accountsMuted;

            if (accountsMuted === 0) {
                retries++;
                console.log("No new accounts found. Scrolling to load more replies...");
                await scrollToLoadMore();
            } else {
                retries = 0;
            }

            if (retries >= 10) {
                console.log("No more replies to process. Stopping...");
                break;
            }
        }

        console.log(`Finished processing. Total accounts muted: ${totalMuted}`);
    }

    console.log("Starting script to mute all blue check accounts...");
    await processRepliesUntilDone();
    console.log("Script finished.");
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment