Created
July 21, 2023 19:24
Revisions
-
Frenchcooc created this gist
Jul 21, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ // Unfollow in batch async function unfollow() { // Retrieve all followings window.following = document.querySelectorAll("[role='button'] .css-901oao.css-16my406.r-poiln3.r-bcqeeo.r-qvutc0") window.waitFor = function (ms) { return new Promise(function(resolve) { setTimeout(resolve, ms) } ) } let counter = 0; // Loop through followings for (let i = 0; i < following.length; i++) { let follow = following[i] if (follow.innerText === 'Following') { // Start unfollow process follow.click() // Wait for the unfollow confirmation modal to show await waitFor(1500); // Confirm unfollow confirmUnfollow() } counter++ } console.log(`Unfollowed ${counter}`) } // Twitter shows a confirmation modal to unfollow // This functions will confirm unfollow function confirmUnfollow () { const button = document.querySelector('[data-testid="confirmationSheetDialog"] [role="button"] span.r-qvutc0') console.log(`Button: ${button}`) if (button && button.innerText === "Unfollow") button.click() } // Unfollow every seconds window.setInterval(unfollow,1000)