Skip to content

Instantly share code, notes, and snippets.

@oktak
Last active November 2, 2020 11:43
Show Gist options
  • Save oktak/f400a595cb02a342a6bc16346c2a4204 to your computer and use it in GitHub Desktop.
Save oktak/f400a595cb02a342a6bc16346c2a4204 to your computer and use it in GitHub Desktop.
Facebook Page Invite Like (new layout) 2020-08
/**
* Paste it in the console of a browser tab which is opening the inviting panel.
* You may adjust the BATCHSIZE. It will wait for ~10 seconds for the next batch.
* It will auto load the infinite scroll after ~5 seconds of finishing current batch of invite.
* The 24-hour limitation of inviting per user per page is around 1000 inivte.
*
* Note: CSS selectors are subject to change by Facebook without any notices.
*
* @author: oktak
* @date: 2020-08-17
*/
var count = 0;
var subcount = 0;
var wait = 0;
var BATCHSIZE = 50;
var timer = setInterval(function () {
var inviteButns = document.querySelectorAll('[aria-label="Reactions"] [aria-label="Invite"], [aria-label="心情數量"] [aria-label="邀請"]');
if (inviteButns.length && subcount <= BATCHSIZE) {
wait = 0;
inviteButns[0].scrollIntoView();
setTimeout(function () {
inviteButns[0].click()
}, 800);
count = count + 1;
subcount = subcount + 1;
}
if (count > 900) {
clearInterval(timer);
subcount = 0;
console.log(`Timer Cleared`)
}
if (subcount > BATCHSIZE) {
subcount = subcount + 1;
if (subcount > BATCHSIZE + 7) {
subcount = 0;
}
}
console.log(`total: ${count}, batch: ${subcount}, wait: ${wait}`)
wait = wait + 1;
if (wait > 5) {
document.querySelectorAll('[aria-label="Reactions"] div[data-visualcompletion="ignore-dynamic"] + div:last-child, [aria-label="心情數量"] div[data-visualcompletion="ignore-dynamic"] + div:last-child')[0].scrollIntoView();
}
if (wait > 40) {
clearInterval(timer);
console.log(`Timer Cleared`)
}
}, 1500);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment