Skip to content

Instantly share code, notes, and snippets.

@Peleg
Created November 27, 2014 21:31
Show Gist options
  • Save Peleg/03bfa16a6937f8bddc83 to your computer and use it in GitHub Desktop.
Save Peleg/03bfa16a6937f8bddc83 to your computer and use it in GitHub Desktop.
Facebook Birthday Liker - likes your friends' posts for your birthday
/**
*
* Facebook Birthday Liker -
* Likes your friends' posts for your birthday
*
* Usage:
* 1. Face the fact that you're an ungrateful, lazy being
* 2. Paste the following code in your console
*
*/
!function (d) {
'use strict';
Node.prototype.getElementsByRegex = function(q, r) {
return [].slice.call(this.querySelectorAll(q))
.filter(function (el) { return r.test(el.innerText); });
};
var _postsList =
// Assuming at least one of your friends is traditional.
d.getElementsByRegex('ul.uiCollapsedList', /happy birthday/i)[0];
var _postsCount =
// Assuming it is your birthday
+d.getElementsByRegex('h5', /\d+ friends posted on your timeline for your birthday./)[0].innerText.match(/\d+/);
var _moreLink;
function _loadAllPosts (cb) {
if (_postsList.children.length === _postsCount) return cb();
(_moreLink = _postsList.getElementsByRegex('a', /^see \d+ more posts$/i)[0]) && _moreLink.click();
setTimeout(function () {
_loadAllPosts(cb);
}, 1000);
}
function _likeEmAll () {
_postsList
.getElementsByRegex('a.accessible_elem', /^like$/i)
.forEach(function (el) { el.click(); });
}
_loadAllPosts(function () {
_likeEmAll();
delete Node.prototype.getElementsByRegex;
});
}(document);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment