Skip to content

Instantly share code, notes, and snippets.

@alexalexandrescu
Created February 22, 2017 17:01
Show Gist options
  • Save alexalexandrescu/1c41efdc8329b9b901802eff46adde40 to your computer and use it in GitHub Desktop.
Save alexalexandrescu/1c41efdc8329b9b901802eff46adde40 to your computer and use it in GitHub Desktop.
InstaLikesClass
class InstaAllLikes {
constructor() {
this.heartClass = '.coreSpriteHeartOpen';
this.nextButton = '._de018.coreSpriteRightPaginationArrow';
this.minInterval = 5;
this.maxInterval = 20;
this.likeCount = 0;
this.timeout;
const popUp = document.querySelector('._n3cp9._d20no');
if(popUp) {
this.cycle();
} else {
throw 'Logic to open popup not implemented';
}
}
cycle() {
console.info(`Liked ${this.likeCount} on this profile`);
this.nextButtonEl = document.querySelector(this.nextButton);
if (this.nextButtonEl && this.likeCount <= 999) {
this.timeout = setTimeout(() => {
this.clickLike();
}, this.randomInterval * 1000);
} else {
console.log('end script');
}
}
clickLike() {
const button = document.querySelector(this.heartClass);
if(button) {
button.parentElement.click();
this.likeCount++;
}
setTimeout(() => {
this.clickNext();
}, 500);
}
clickNext() {
this.nextButtonEl.click();
clearTimeout(this.timeout);
this.cycle();
}
get randomInterval() {
return Math.floor(Math.random() * (this.maxInterval - this.minInterval + 1) + this.minInterval);
}
}
new InstaAllLikes();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment