Last active
December 10, 2020 04:06
-
-
Save raghav4/66f2d222c4a0badb1fa9143d03e3cfd9 to your computer and use it in GitHub Desktop.
Script to like all the Instagram posts!
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
function doSomething(random) { | |
var firstLike = document.querySelector( | |
'section.ltpMr.Slqrh > span.fr66n > button > div > span > svg[aria-label="Like"]' | |
); | |
if (firstLike) { | |
firstLike.scrollIntoView({ | |
behavior: "smooth", | |
block: "center", | |
inline: "nearest", | |
}); | |
var closestElement = firstLike.closest("button"); | |
console.log("clicked...\n"); | |
closestElement.click(); | |
} | |
console.log("waiting for " + random + " miliseconds\n"); | |
} | |
(function loop() { | |
var min = 1000; // min 1 second | |
var max = 2000; // max 2 seconds | |
var random = Math.floor(Math.random() * (+max - +min)) + +min; | |
var today = new Date().getHours(); | |
console.log("current hour: " + today + "\n"); | |
var start = 9; // start liking after this hour | |
var end = 20; // stop liking after this hour | |
if (today >= start && today <= end) { | |
// Between | |
// On | |
setTimeout(function () { | |
doSomething(random); | |
loop(); | |
}, random); | |
} else { | |
// Off | |
if (start < today) { | |
var diff = start - today; | |
} else { | |
var diff = today - start; | |
} | |
console.log("diff * 3600000: " + Math.abs(diff) * 3600000 + "\n"); | |
console.log( | |
"waiting for " + Math.abs(diff) + " hours until " + start + "\n" | |
); | |
setTimeout(function () { | |
loop(); | |
}, Math.abs(diff) * 3600000); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Without Scroll