Skip to content

Instantly share code, notes, and snippets.

@aholmes
Created May 1, 2014 07:06
Show Gist options
  • Save aholmes/2353c5ed5d12f9099eea to your computer and use it in GitHub Desktop.
Save aholmes/2353c5ed5d12f9099eea to your computer and use it in GitHub Desktop.
var queued = [], scrollTimeout, waitForQueueTimeout;
function queueMore() {
Array.prototype.filter.call(document.querySelectorAll('a.UFILikeLink[title*="Like this"]'), function(a) {
if (queued.indexOf(a) === -1) {
queued.push(a);
}
});
}
function getRandomInt (min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function likeNextComment() {
window.setTimeout(function() {
console.log('likeNextComment');
var a;
// if there are 'like' buttons queued, grab the first off the stack and like it
if (queued.length !== 0) {
do
{
a = queued.shift();
// Just incase an item was added to the stack again before we were able to like it, grab the next one
} while (a.title === 'Unlike this comment' || a.title === 'Unlike this');
a.click();
}
likeNextComment();
}, getRandomInt(1500, 6000));
}
function waitForQueueToclear() {
console.log('waitForQueueToClear');
waitForQueueTimeout = window.setInterval(function() {
if (queued.length === 0) {
window.clearInterval(waitForQueueTimeout);
startScrollyolyol();
}
}, 500);
}
function scrollyolyol() {
console.log('scrollyolyol');
if (queued.length > 50) {
window.clearInterval(scrollTimeout);
waitForQueueToclear();
}
window.scrollTo(0, document.body.clientHeight);
queueMore();
}
function startScrollyolyol() {
// scroll the window every 100ms to get more things to like
scrollTimeout = window.setInterval(scrollyolyol, 100);
}
// call this to get rolling.
// startScrollyolyol(); likeNextComment();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment