Skip to content

Instantly share code, notes, and snippets.

@zettca
Last active May 22, 2018 00:54
Show Gist options
  • Save zettca/04329f907d12b730c79a to your computer and use it in GitHub Desktop.
Save zettca/04329f907d12b730c79a to your computer and use it in GitHub Desktop.
Instagram auto-liker
(function (delay, type) {
const g = (c) => document.getElementsByClassName(c);
const pics = g('_si7dy');
function iteration() {
const heart = g((type === 'like') ? 'coreSpriteHeartOpen' : 'coreSpriteHeartFull')[0];
heart && heart.click();
g('coreSpriteRightPaginationArrow')[0].click();
}
new MutationObserver((muts) => {
muts.forEach((mut) => {
if (mut.addedNodes.length) {
setTimeout(iteration, delay);
new MutationObserver((muts) => {
muts.forEach((mut) => {
if (mut.addedNodes.length) setTimeout(iteration, delay);
});
}).observe(mut.addedNodes[0].firstChild.children[1].firstChild.firstChild, { attributes: true, childList: true, characterData: true });
}
});
}).observe(document.body, { childList: true });
})(100, 'like');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment