Skip to content

Instantly share code, notes, and snippets.

@itsmnthn
Last active January 23, 2021 16:41
Show Gist options
  • Save itsmnthn/8ddc2e046aa3813b3e23a184daa0e7a7 to your computer and use it in GitHub Desktop.
Save itsmnthn/8ddc2e046aa3813b3e23a184daa0e7a7 to your computer and use it in GitHub Desktop.
Instagram hashtag or profile post popup liker
/**
* @author Manthankumar Satani <satanimanthan@gmail.com>
* @version 1.0.0
*/
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
function getLikeBtns(xpf, xpath) {
var items = [];
xpf(xpath).forEach(item => {
if (
item.childNodes[0].childNodes[0].childNodes[0].getAttribute(
"aria-label"
) === "Like"
)
items.push(item);
});
return items;
}
async function startLiking(xpf, scrollInterval, likeInterval) {
var likes = 0;
setInterval(async function() {
var xpath = '//span[@class="fr66n"]/button';
var likeButtons = getLikeBtns(xpf, xpath);
likeButtons.forEach(async btn => {
btn.scrollIntoView();
btn.click();
likes += 1;
await sleep(likeInterval);
});
console.log("Liked", likes);
// Next click on popup
try {
var nextBtn = document.querySelector(
"a._65Bje.coreSpriteRightPaginationArrow"
);
nextBtn.click();
} catch (e) {}
}, scrollInterval);
}
startLiking(window.$x, 3000, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment