Last active
December 19, 2021 18:04
-
-
Save clins1994/84a7f7ba0cbb813757b8cbfa7b4e1259 to your computer and use it in GitHub Desktop.
Unfollow Everyone on Instagram
This file contains 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
// HOW TO RUN IT ON GOOGLE CHROME | |
// 1. OPEN INSTAGRAM | |
// 2. OPEN LIST OF FOLLOWERS | |
// 3. OPEN DEVELOPER TOOLS | |
// 4. COPY EVERYTHING HERE CTRL + A | |
// 5. PASTE EVERYTHING IN DEVELOPER TOOLS CONSOLE | |
// 6. CLICK ENTER | |
// THERE YOU WILL SOON HAVE NO FRIENDS | |
const FOLLOWING_BUTTON_TEXT = 'フォロー中' // CHANGE THIS TO YOUR LANGUAGE | |
const UNFOLLOW_BUTTON_TEXT = 'フォローをやめる' // THIS TOO | |
const MAX_ATTEMPTS_PER_UNFOLLOW = 3 // BUMP THIS IF YOU HAVE WOODEN PC | |
const unfollowSomebody = () => { | |
const followingButton = document | |
.evaluate(`//button[text()="${FOLLOWING_BUTTON_TEXT}"]`, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null) | |
.singleNodeValue | |
if (followingButton) { | |
console.log('Found following button. Clicking ...') | |
followingButton.click() | |
console.log('Clicked following button.') | |
let unfollowButton = document.evaluate(`//button[text()="${UNFOLLOW_BUTTON_TEXT}"]`, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue | |
let attempts = 1 | |
while (attempts < MAX_ATTEMPTS_PER_UNFOLLOW && !unfollowButton) { | |
console.log(`Attempted to find unfollowButton but could not. Retry #${attempts++}`) | |
unfollowButton = document.evaluate(`//button[text()="${UNFOLLOW_BUTTON_TEXT}"]`, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue | |
} | |
if (attempts < MAX_ATTEMPTS_PER_UNFOLLOW) { | |
console.log('Found unfollow button. Scrolling and clicking ...') | |
unfollowButton.scrollIntoView(true) | |
unfollowButton.click() | |
} else { | |
console.log(`Retried ${MAX_ATTEMPTS_PER_UNFOLLOW} times and didn't succeed`) | |
} | |
return false | |
} | |
return true | |
} | |
const timeout = (ms) => new Promise(resolve => setTimeout(resolve, ms)) | |
const randomTimeout = () => (Math.floor((Math.random() * 10) + 1) * 1000) + 30000 | |
const unfollowEveryone = async () => { | |
let shouldStop = false | |
while (!shouldStop) { | |
shouldStop = unfollowSomebody() | |
const unfollowTimeout = randomTimeout() | |
console.log(`Waiting ${unfollowTimeout} seconds. Should stop: ${shouldStop}.`) | |
await timeout(unfollowTimeout) | |
} | |
console.log('You follow no one.') | |
} | |
unfollowEveryone() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I found a better solution for using this for a profile that is not your friend or has not talked to you, I hope this Script works from starting following, what if we reverse that order from inspecting and then try to run this script, not used but will try and update if any possibilities.
use this code and reverse your whole following list, then try this script, hope it will work and you will unfollow the right person.
For more lame explanation please visit https://gist.github.com/jagdishlove/2393f32601054600be06fa4d20df5cb8