Skip to content

Instantly share code, notes, and snippets.

@guiliredu
Last active September 14, 2024 17:48
Show Gist options
  • Save guiliredu/ef83ac2c81452a7116956f3fd73b406d to your computer and use it in GitHub Desktop.
Save guiliredu/ef83ac2c81452a7116956f3fd73b406d to your computer and use it in GitHub Desktop.
Facebook - Script to auto invite people who liked a page post do like the page
var buttons;
buttons = document.getElementsByClassName('_42ft');
for (var i = 0; i < buttons.length; i++) {
if(buttons[i].getAttribute('ajaxify') != null){
if(buttons[i].getAttribute('ajaxify').indexOf('invite') != -1){
buttons[i].click();
}
}
}

How to use

  • Open the facebook window with people yuo want to invite
  • Copy the code and place on your browser url input OR open console and place
  • To use in the browser url input, copy the code below:
javascript:var buttons; buttons = document.getElementsByClassName('_42ft'); for (var i = 0; i < buttons.length; i++) { if(buttons[i].getAttribute('ajaxify') != null){ if(buttons[i].getAttribute('ajaxify').indexOf('invite') != -1){ buttons[i].click(); } } }
@SalimF
Copy link

SalimF commented Oct 23, 2019

I modify the code to have delay 1s you dodn;t nee any sht PRO addons for that here is the cod

javascript:var buttons; var i = 1; buttons = document.getElementsByClassName('_42ft'); function myLoop () { setTimeout( function () { if(buttons[i].getAttribute('ajaxify') != null){ if(buttons[i].getAttribute('ajaxify').indexOf('invite') != -1){ buttons[i].click(); } } i++ ; if (i < 10) { myLoop() ; } } , 1000 ) } myLoop();

@guiliredu
Copy link
Author

I modify the code to have delay 1s you dodn;t nee any sht PRO addons for that here is the cod

javascript:var buttons; var i = 1; buttons = document.getElementsByClassName('_42ft'); function myLoop () { setTimeout( function () { if(buttons[i].getAttribute('ajaxify') != null){ if(buttons[i].getAttribute('ajaxify').indexOf('invite') != -1){ buttons[i].click(); } } i++ ; if (i < 10) { myLoop() ; } } , 1000 ) } myLoop();

Thanks, dude, will update the code with your timeout idea.

@SalimF
Copy link

SalimF commented Oct 24, 2019

Thanks, dude, will update the code with your timeout idea.

BTW I didn't doing complete test on it , as it's do not have scroll feature to see more likes , Anyway you all should be aware of this methods since I got warning from FB for spam even I was using delay , I guess FB think you won't sent invite to more than 80% of people who like your post . Last I use this add-on now https://chrome.google.com/webstore/detail/invite-post-likers-to-lik/dfhnkeijhilolcebpchcdiclpejojodb/

@KareemElhennawy
Copy link

Hi all,

I'm facing this issue

image

@rohitcoder
Copy link

is there any alternative for server-side scripts? i want to run CRON jobs, i don't think it's possible with JS.

@SalimF
Copy link

SalimF commented Jan 14, 2020

i don't think it's possible with JS.

You can use PhantomJS or Headless Chrome ( and inject/load JS code to it ) if PhantomJS didn't work and run it from any linux server via command line , BTW you need to increase the delay time a lot since you're using (server which runs 24/7) or better you could make the script pause the invitation for hours and make the account do anything else , son didn't get suspended from facebook .

@neojin12355
Copy link

Thank you so much ! So saved me hours of repetitive work !

@Mishef
Copy link

Mishef commented Mar 22, 2020

Hello everyone! Is there a new version of a script that works with new Facebook design?

@BaapJaan
Copy link

BaapJaan commented Apr 13, 2020

I did this one Credit goes to Shahriar Shojib

async function invite() {
	let buttons = document.getElementsByClassName('_42ft');
	for (var i = 0; i < buttons.length; i++) {
		if (buttons[i].getAttribute('ajaxify') != null) {
			if (buttons[i].getAttribute('ajaxify').indexOf('invite') != -1) {
				await timeout(Math.ceil(Math.random() * 10000));
				buttons[i].click();
			}
			
		}
	}

}
function timeout(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
}
invite();

@Mishef
Copy link

Mishef commented Apr 13, 2020

@BaapJaan It didn't let me to insert that code into URL address of bookmark in Chrome.

@BaapJaan
Copy link

@BaapJaan It didn't let me to insert that code into URL address of bookmark in Chrome.

Insert it in your console How?

@Shurshik
Copy link

Shurshik commented May 14, 2020

@BaapJaan It didn't let me to insert that code into URL address of bookmark in Chrome.

Insert it in your console How?

You cannot use the code in console anymore, it's more complicated, just download and use any extension like this (with top reviews): https://chrome.google.com/webstore/detail/oobofacgjpheigmglnjjlhfolhcamaia?hl=en

@Shurshik
Copy link

Hello everyone! Is there a new version of a script that works with new Facebook design?

The one I use in chrome works with the new design very well

@Agostinho78
Copy link

Is there a script to invite anyone whole LIKED somebody else's page or group to come LIKE my page:

Thanks,
Agostinho Domingos
Founder, CEO, Director
https://www.ladilsa.com

@Shurshik
Copy link

Is there a script to invite anyone whole LIKED somebody else's page or group to come LIKE my page:

You are asking for an impossible thing. There is no way to invite people from other pages.

@GHSkyKam
Copy link

GHSkyKam commented Aug 2, 2020

The code could be further simplified to this one-liner for the Chrome address bar.

Note that it won't work with a simple copy and paste into the address bar because Chrome blocks any string that starts with javascript: in the address bar. Select from the second character onward, manually type "j" in the address, paste in what you copied, and hit enter.

javascript:(function() {Array.from(document.getElementsByClassName('_42ft')).map(function(x){x&&x.getAttribute('ajaxify')&&x.getAttribute('ajaxify').indexOf('invite')!=-1&&x.click();});})();

@Shurshik
Copy link

Shurshik commented Aug 2, 2020

The code could be further simplified to this one-liner for the Chrome address bar.

Note that it won't work with a simple copy and paste into the address bar because Chrome blocks any string that starts with javascript: in the address bar. Select from the second character onward, manually type "j" in the address, paste in what you copied, and hit enter.

javascript:(function() {Array.from(document.getElementsByClassName('_42ft')).map(function(x){x&&x.getAttribute('ajaxify')&&x.getAttribute('ajaxify').indexOf('invite')!=-1&&x.click();});})();

This will not work. Facebook will disable invite pretty quickly. You need to use random timing on clicking and on scrolling... The best way is to use any free script, there are hundreds of them as extensions in chrome store

@GHSkyKam
Copy link

GHSkyKam commented Aug 3, 2020

This will not work. Facebook will disable invite pretty quickly.

I don't know, I manage a medium size page and I use it everyday. Of course your mileage may vary.

The key is exposing all the Invite buttons before deploying this script, because facebook count this as one single click. You can use an autohotkey script to do this.

#j::   ; Windows-J

; Keeps scrolling down until the shift key is pressed
loop {
  Send {WheelDown 4000} ; scroll down
  Sleep 500
  if (GetKeyState("Shift")) 
     break
}
; Move the mouse to the right a little to indicate that the script ended
MouseMove 800,0,,R

return

@Ceasarsalad-Code
Copy link

Yes, we need timeout between clicks, but there is a free extension, as I post before, so people can use it :)

It's very useful, But what is the time out between clicks ?

@Shurshik
Copy link

Shurshik commented Sep 1, 2020

Yes, we need timeout between clicks, but there is a free extension, as I post before, so people can use it :)

It's very useful, But what is the time out between clicks ?

Random about 2-4 seconds. And also you can change it in some versions

@Shurshik
Copy link

Some useful updates I found:

  1. BIG pages (more than 100 000 likes) can now invite post likers again in the new interface!
  2. If you don't like new interface - just use this extension: https://chrome.google.com/webstore/detail/switch-to-classic-design/oancckmjgaoejmbedngcoiakblhacbog and it will re-enable classic version on your browser!

@andrecostamarques
Copy link

Is there anyway to invite someone whom liked a page your not the owner?

@netusipt
Copy link

netusipt commented Aug 23, 2021

I highly recommend this browser extension - Firefox, Chrome, Edge.
It saves me so much time and it's free.

@Shurshik
Copy link

I highly recommend this browser extension - Firefox, Chrome, Edge.
It saves me so much time and it's free.

I can see the malware there. THis extension was just uploaded. DO NOT USE IT. Just search on google and use famous extensions released years ago with thousands on downloads, you will be more secure.

@netusipt
Copy link

It's not malware. Look at the reviews on Firefox. I developed this extension. I build it primarily for my own use. Recently I decided to share it with others. It's just another option. Download whatever extension you want. Just saying it's not malware, it works and it's free. Actually, all extensions are reviewed before they are published. Here's my website - https://likeinviter.herokuapp.com/

@Shurshik
Copy link

It's not malware. Look at the reviews on Firefox. I developed this extension. I build it primarily for my own use. Recently I decided to share it with others. It's just another option. Download whatever extension you want. Just saying it's not malware, it works and it's free. Actually, all extensions are reviewed before they are published. Here's my website - https://likeinviter.herokuapp.com/

Reviews? There is 1 good review, lol! I don't see any sense to create own extension when there are many of them, for years. Also no sense to give the extension access to your own domain, it's not secure. Google checks extension but not enough. For me this is big no.

@piranhap
Copy link

2024 and wondering what everyone else is using ;-;

@Shurshik
Copy link

2024 and wondering what everyone else is using ;-;

I use this paid extension: https://www.invitelikecomment.com/en/ at the end it was better to pay and be sure the extension is safe, this link is here since 2019 and still works

@piranhap
Copy link

piranhap commented May 3, 2024

I understand but part of me feels like there's gotta be some free open-source version for a script, right?

@Shurshik
Copy link

I understand but part of me feels like there's gotta be some free open-source version for a script, right?

As I know there is no working open source version. Now only the paid one works perfectly, free version isn't good anymore

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