Skip to content

Instantly share code, notes, and snippets.

@ironmaniiith
Last active January 7, 2017 07:34
Show Gist options
  • Save ironmaniiith/4c3bc6a5c2dda5f1c49b to your computer and use it in GitHub Desktop.
Save ironmaniiith/4c3bc6a5c2dda5f1c49b to your computer and use it in GitHub Desktop.
;(function() {
var SCROLL_HEIGHT = 1e20;
function final_greeting() {
alert("Share this to make Felicity Awesome!");
}
function scrollToBottom(el, cb) {
// Scroll to the bottom of target el
var x = setInterval(function() {
console.log('Scrolling to bottom!');
var isScrolledToBottom = el.scrollHeight - el.clientHeight <= el.scrollTop + 1;
el.scrollTop = SCROLL_HEIGHT;
if (isScrolledToBottom) {
clearInterval(x);
if (cb && typeof cb === 'function') cb();
}
}, 1000);
}
function invite() {
var invite_links = document.getElementsByClassName('_39g5'),
invite_link;
for (var i = 0; i < invite_links.length; i++) {
if (invite_links[i].innerHTML.indexOf('Invite friends to like') > 0) {
invite_link = invite_links[i].getElementsByTagName('div')[0];
}
}
if (invite_link === undefined) {
alert("Unable to find invite link!")
return;
}
invite_link.click();
var checker = setInterval(function() {
var form = document.getElementsByClassName('_s');
if (form && form.length) {
form = form[0];
var listView = form.getElementsByClassName('listView clearfix');
var li = form.getElementsByClassName('fbProfileBrowserListItem');
if (listView.length && li.length) {
clearInterval(checker);
setTimeout(function() {
var box = document.getElementsByClassName('fbProfileBrowserResult scrollable threeColumns hideSummary')[0];
scrollToBottom(box, function() {
console.log('Invite started!');
var a = document.getElementsByClassName('uiButton _1sm'),
i = 0;
var x = setInterval(function(){if(i>=a.length){clearInterval(x); final_greeting();} else { a[i].click(); i++;}}, 50);
});
}, 5000);
return;
}
}
console.log('Skipping');
}, 1000);
}
invite();
})();
@ironmaniiith
Copy link
Author

ironmaniiith commented Jan 13, 2016

How to run the script

  1. Go to Felicity page and open the console (by typing F12).
  2. Paste the script in the console and press enter.

Share this script to make felicity more awesome 😄
#FelicityIsComing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment