X
Tap here to go to the mobile version of the site.

منتدى الدعم

userscript to click button automatically on refresh

Posted

Using Firefox.

I'm curious if there's any possible way to have a script automatically click on a specific submit button every 2-3 seconds for example. This is for backend server administration purpose I need to add a bunch of submissions from a drop down menu. Screenshot attached as an example (full address censored for privacy).

Using Firefox. I'm curious if there's any possible way to have a script automatically click on a specific submit button every 2-3 seconds for example. This is for backend server administration purpose I need to add a bunch of submissions from a drop down menu. Screenshot attached as an example (full address censored for privacy).
Attached screenshots
Wesley Branton
  • Top 10 Contributor
639 solutions 5225 answers

You could easily do this using the click() method within a function that is triggered by a setTimeout() method in Javascript.

For example, your Javascript file would look similar to this:

function clickButton() {
     button.click();
     setTimeout(clickButton,2000);
}

// First call
clickButton();

That would run infinity. If you want to the function to only run a finite amount of times, you would have to implement a counter variable that would increment each time the function runs.

Naturally, this won't bypass any websites that have a submission time limit to prevent sending X number of requests within a certain period of time and you may run into issues if the website reloads itself after the submit button is clicked, which is usually the default behavior of such a button.

You could easily do this using the [https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click <code>click()</code>] method within a function that is triggered by a [https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout <code>setTimeout()</code>] method in Javascript. For example, your Javascript file would look similar to this: <pre><nowiki>function clickButton() { button.click(); setTimeout(clickButton,2000); } // First call clickButton(); </nowiki></pre> That would run infinity. If you want to the function to only run a finite amount of times, you would have to implement a counter variable that would increment each time the function runs. Naturally, this won't bypass any websites that have a submission time limit to prevent sending X number of requests within a certain period of time and you may run into issues if the website reloads itself after the submit button is clicked, which is usually the default behavior of such a button.

Question owner

Thanks Wesley. I'm sorry, I never used Userscript or anything. Could you please explain how this would work?

Thanks Wesley. I'm sorry, I never used Userscript or anything. Could you please explain how this would work?
Wesley Branton
  • Top 10 Contributor
639 solutions 5225 answers

You would need the Greasemonkey addon installed and they have all of the information about using and implementing the program on their wiki.

You would need the [https://addons.mozilla.org/firefox/addon/greasemonkey/ Greasemonkey addon installed] and they have all of the information about using and implementing the program [https://wiki.greasespot.net/Main_Page on their wiki].