Created
July 21, 2023 19:24
-
-
Save Frenchcooc/f17fb69fe55ec6db0a989331ab9ff3bc to your computer and use it in GitHub Desktop.
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 characters
// 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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment