How to automatically click a submit button on a web page every few minutes?
You can trigger a click event every second using javascript like so
setInterval(() => {
document.querySelector('button.refresh-data').click()
}, 1000)
Now that said clicking on the button only means calling a function, so you could also call it directly
setInterval(refreshdata, 1000)
I'm not sure why you would want to attempt triggering this when the page does not exist or when your computer is off, as by definition the page (and your code) does not exist at this time. If some routine logic needs to happen that will likely be done in your backend codebase, independently from your frontend application.
How to automatically click a button on a website on daily basis
There is a name for that - Crawler.
You can use the Puppeteer library to create a headless web browser and simulate any kind of action.
The production may be on a public server, like Heroku or Deta.
Puppeteer dev web documentation
I want to auto click a button on the website as the extension is clicked
You can try this code in your background script:
chrome.browserAction.onclicked.addListener(tab => {
chrome.tabs.executeScript(tab, {code:
`var theButton = document.querySelector("button");
if (theButton) theButton.click();`});
});
When your extension's icon (browser action) is clicked, it will click on the first button of the active webpage. If you want a specific button, refine the selector in document.querySelector
call.
How to auto click an input button
I see what you really want to auto submit the form. This would do it:
window.onload = function(){
var button = document.getElementById('clickButton');
button.form.submit();
}
EDIT
If what you want is really auto submit the form automatically n times, each second, whis would do:
window.onload = function(){
var button = document.getElementById('clickButton'),
form = button.form;
form.addEventListener('submit', function(){
return false;
})
var times = 100; //Here put the number of times you want to auto submit
(function submit(){
if(times == 0) return;
form.submit();
times--;
setTimeout(submit, 1000); //Each second
})();
}
Cheers
How to Automatically Click Button on a Webpage
i think if you follow the idea that i will show, you will catch the solution
consider that you have two buttons one called "Call set time out" and another is your desired button "Add to cart"
and on "Call set time out" click event you want to call "Add to Cart" button event so you should do the following
the html will be
<input type="button" id = "Call-set-time-out" value= "Call set time out" />
<input type="button" id = "add-to-cart-button" value= "Add to cart"/>
and the jquery script will be
$( "#Call-set-time-out" ).click(function() {
$("#add-to-cart-button").trigger('click');
});
$( "#add-to-cart-button" ).click(function() {
alert( "add-to-cart-button .click() event called." );
});
i hope this will help you and good luck for you journey in Jquery world
Related Topics
Check If a Number Has a Decimal Place/Is a Whole Number
Regular Expression to Check Only One Decimal Point
Regex Pattern to Match At Least 1 Number and 1 Character in a String
How to Remove Special Character from Json Without Parsing
Show/Hide Select Options Based on Value of Another Select Using Javascript/Jquery
Passing Variable from One Js to Another Js File in Nodejs
How Exactly Use and Update the Global Variables in React-Native
Angular Conditional Readonly/Disable on Input Fields
Convert Image from Url to Base64
Most Efficient Method to Groupby on an Array of Objects
Filtering Multiple Items With Es6 Array Functions
How to Print Star Pattern in JavaScript in a Very Simple Manner
How to Cancel Ongoing Http Requests When There's a New Requests in Angular 6 With Rxjs 6
Expected to Return a Value At the End of Arrow Function Array-Callback-Return on Filter Function
How Add a New Key/Value Pair to a Json Object
React Native Flatlist With Clickable Items