Last active
January 7, 2017 07:34
-
-
Save ironmaniiith/4c3bc6a5c2dda5f1c49b to your computer and use it in GitHub Desktop.
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() { | |
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(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to run the script
Share this script to make felicity more awesome 😄
#FelicityIsComing