Last active
May 25, 2020 18:40
-
-
Save krrskl/9991f4647fcfd3f8450adf1e6154ce99 to your computer and use it in GitHub Desktop.
Unfollow all users of a profile in 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
(() => { | |
let unfollowButtons = []; | |
const notUnFollowUsers = []; | |
const _getButtonsActions = () => document.querySelectorAll(".-nal3"); | |
const _getUnfollowsButtons = () => [ | |
...document.querySelectorAll(".sqdOP.L3NKy._8A5w5"), | |
]; | |
const _confirmUnFollow = () => document.querySelector(".aOOlW.-Cab_").click(); | |
const _getContainer = () => document.querySelector(".PZuss"); | |
const _plusOrMinus = () => (Math.random() < 0.5 ? -1 : 1); | |
const _randomTimeout = () => | |
_plusOrMinus() * Math.floor(Math.random() * 500) + 3000; | |
const _scrollDown = () => | |
(_getContainer().scrollTop = _getContainer().scrollHeight); | |
/* remove edit profile Button */ | |
document.querySelector(".sqdOP.L3NKy._4pI4F._8A5w5").remove(); | |
_getButtonsActions()[2].click(); | |
setTimeout(() => { | |
unfollowButtons = _getUnfollowsButtons(); | |
_unFollow(); | |
}, _randomTimeout()); | |
function _unFollow() { | |
try { | |
if (unfollowButtons.length === 0) { | |
throw new Error("No hay usuarios."); | |
} | |
current = unfollowButtons.shift(); | |
const userName = current.parentNode.parentElement.children[1].children[0].children[0].children[0].children[0].innerText | |
.split(" ") | |
.join(""); | |
if (!notUnFollowUsers.includes(userName) || notUnFollowUsers.length === 0) { | |
current.click(); | |
setTimeout(() => _confirmUnFollow(), 500); | |
} else { | |
console.log(`Ignorando el usuario ${userName}`); | |
} | |
const _createTimeOut = () => | |
setTimeout(() => _unFollow(), _randomTimeout()); | |
timeOut = _createTimeOut(); | |
if (unfollowButtons.length === 1) { | |
clearTimeout(timeOut); | |
_scrollDown(); | |
setTimeout(() => { | |
unfollowButtons = _getUnfollowsButtons(); | |
_createTimeOut(); | |
}, 2000); | |
} | |
} catch (error) { | |
throw new Error( | |
"Ha ocurrido un error al lanzar la acción de [UNFOLLOW]", | |
error | |
); | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment