Basically, I have this piece of Javascript below:
javascript:var inputs = document.getElementsByClassName('uiButton _1sm');
for(var i=0; i<inputs.length;i++) {
inputs[i].click();
}
The user simply loads up a Facebook page, clicks on the 'See All' under "Invite Your Friends to Like This Page", scroll all the way down, then paste the above code into the console.
I was wondering if there's any way to modify this script to ensure that it automatically scrolls down to the bottom of the 'Friends List' before it starts inviting?
And maybe even a 0.3 second delay between each invite?
Thanks
You can scroll down using window.scrollTo(0,document.body.scrollHeight); before inviting all the the friends. The scrollTo() method scrolls the document to specified coordinates. So as you call this, the document will automatically scroll until it reaches the end. You need to use setInterval() to call this, and as soon as the end is reached you would need to clearInterval().
Have a look at my chrome extension on Github for inviting all friends to like any Facebook page here (Github). Also you can download my chrome extension from the google chrome store.
document.getElementsByClassName('headerTextLink')[0].click(); //Open Layer
window.setTimeout( function(){ //Timeout for 3 seconds
var inputs = document.getElementsByClassName('uiButton _1sm');
for(var i=0; i<inputs.length;i++) {
inputs[i].click();
}
}, 3000);
I hope, this is only for you. It's a dirty trick for inviting all friends at once.
You should think about whom you are sending an invitation. Otherwise it is spam.
Well , let this message. Here in this article I will share some way invite all friends to your Facebook fan page a click . We just need a simple script that automatically invite all your friends by clicking on a button to use . So , follow these simple steps and enjoy ..
Open your Facebook page , where you want to invite your friends.
Now simply navigate to the public to build > Invite option.
Now , a dialog box will be the option to invite all your friends
name.
Press F12 to open inspect element tab.
Go to the Console, tab and copy and paste the following script.
var inputs = document.getElementsByClassName('uiButton _1sm');
for(var i=0; i<inputs.length;i++)
{
inputs[i].click();
}
After the paste code above in the list of the console, then hit enter and see the magic ! all your friends will be invited to your Facebook page.
Related
I have searched a lot of information about this but have not found the solution yet.
My problem is the following, I am creating an extension to speed up the movement through several web pages, I have managed it with many of them, but I have come to some where I cannot simulate a click with Javascript and I don't know how to do it.
One of the pages is this: https://sports.betway.es/es/sports/in-play The page is in Spanish domain, therefore I do not know if they can access it from another country (without vpn), although I think that with domain ".com" it works.
The code is as follows, it's pretty simple.
var deportesActivos = document.getElementsByClassName("categoryListItemWrapper contentSelectorItemButton")
for(let i=0;i<deportesActivos.length;i++){
let nombre = deportesActivos[i].lastChild.firstChild.innerText
if(nombre == data.deporte){
deportesActivos[i].click()
}
}
deportesActivos I collect the DIV elements with that class from the page.
deportesActivos[i].lastChild.firstChild.innerText I extract the text of each element
if(nombre == data.deporte){
deportesActivos[i].click()
}
When it matches, click to enter the link.
The problem is that the click does not simulate me.
I have bought exactly the element that you click on, I have clicked manually and it works, I have tried to click on other elements of the web page and it does not work, I have tried to give a "listener on click" to the element and it does not work either.
The HTML of the page is as follows:Image with HTML Code of the website
I don't know if this helps but on website build with Ionic app neither works
The click event does not fully simulate a user click. It just fires the onClick handler on the element that you are targeting (and any parents).
If your are just redirecting to a new URL when the button is clicked, you could just do that in your loop instead.
// get the links, not the buttons
var deportesActivos = document.getElementsByClassName("categoryListItemWrapper contentSelector");
for (let i=0; i < deportesActivos.length; i++) {
// Drill down one extralevel to get the button text
let nombre = deportesActivos[i].firstChild.lastChild.firstChild.innerText;
if (nombre === data.deporte) {
// Redirect to the href in the link
window.location.href = deportesActivos[i].href;
}
}
I am building a web app and I am trying to do a function where there is a popup confirm box that shows after the user has been inactive for 10 minutes. When the popup opens the user can choose to continue being logged in or not. I need this box to close down after 1 minute if they have not answered the popup. How can I do this. Everything else works fine.
This is my code:
function checkTime () {
setTimeout (function () {
var dialog = confirm ("Do you want to continue being logged in?");
if (dialog == true) {
checkTime ();
} else {
window.location = 'LOGOUT URL';
}
}, 10000);
};
You cannot do that with the native confirm() as it stops JavaScript run on that page until the user has clicked on it.
So, You have to create a plugin for confirm-box or try someone else.
And they often look better, too. :)
you can't make the confirm close itself - as a thought path my bank has the same sort of thing on their on-line banking system - quite simply if you walk away and come back, it you've been longer than 10 minutes it doesn't matter what you chose it apologizes and logs you out anyway
the dialog requires human interaction it can not be overridden for security reasons. in order to do what you are trying to you would need to use a modal solution (this can be achieved with a small amount of js and some css if you don't want to use a third party solution)
I know it's not the answer you were looking for I'm sorry but hopefully it gives you some ideas for options
I need to prompt the user to a site usability survey when the user navigate away from the site or try to close the site window. For example, when the user closes the window of my site, I want to show a prompt to say "do you want to take a survey?" , if the user clicks yet, open a new window with the survey link.
Is there a way in GWT to achieve that?
I have tried using
Windows.addWindowCLosingHandler
but that only gave me the ability to set a message to ask if the user want to stay on the site or now using ClosingEvent event , event.setMessage("sure?");
thanks
You can use window.onunload but that will be called whenever the user changes the page
Also see here: How to catch user leaving a page and cancelling it
Use the unload method on the body:
<body onUnload="unloadFunction(); return false;">
Then something like this for your js:
function unloadFunction()
{
if (confirm("Would you like to take our servey?"))
{
window.location.href = 'location_of_your_survey'
}
return false;
}
I want to display my licence agreement when the user clicks on any link on the page and prevent the link from taking the user anywhere. I need a way to make any click on the page show the code I want. Is there an easy way to do it? Like a scripts that tells the browser "when the user clicks something show this...".
Thanks a lot for any info
Plain javascript (but without any test for existing onclick handlers):
in the head add
<script>
var disclaimer="This link is not our responsibility - click ok to continue"
window.onload=function() {
var links = document.links;
for (var i=0, n=links.length;i<n;i++) {
links[i].onclick=function() { return confirm(disclaimer);}
}
}
</script>
Jquery:
$('a').click(function() {
// show whatever you want
});
I am trying to create a Facebook Dialog using the new improvements that were released last week.
http://developers.facebook.com/blog/post/437
What I want is to be able to have a link so when it's clicked a popup is generated, or have it show up in the page. I've tried putting it in a DIV and then showing with JQuery but it won't center on the page. I've gotten the code to work for posting to the users wall... just don't know how to either format the JS code and or create the link for the popup.
Thanks in advance!
As long as you have the Facebook js on your page, it's as easy as this to create a friend invitation:
<script>
FB.ui(
{
method: 'friends.add',
id: fbid // assuming you set this variable previously...
},
function(param){
// If you have FireFox + FireBug or Chrome + developer tools:
console.log(param); // log response to javascript console
// If they cancel params will show:
// {action:false, ...}
// and if they send the friend request it'll have:
// {action:true, ...}
// and if they closed the pop-up window then:
// param is undefined
}
);
</script>
You can test this by using the javascript console app on Facebook:
http://developers.facebook.com/tools/console
Paste in the script above, including the tags, or click the "Examples" button on the bottom of the text area and find the "fb.ui — friends.add" example.