Automatic click is to prevent the anti-hanging function of the website.
Is there a way to automatically click when a button appears?
Button code
<button type="button" class="swal2-confirm swal2-styled" style="background-color: rgb(48, 133, 214);
border-left-color: rgb(48, 133, 214); border-right-color: rgb(48, 133, 214);">
確定</button>
Grab the button and use the .click() method on it. You will likely have to do it on some event like DOMContentLoaded or using a setTimeout etc.
1 Like
umm… I may not understand much, Can you show me example?
Give an id to your button, then using the click method and the DOMContentLoaded lasjorg suggested do something like this:
window.addEventListener('DOMContentLoaded', (event) => {
document.getElementById("idGivenToButton").click();
});
If you want to wait for stylesheets, images, and subframes to finish loading, use the load event instead
Without knowing the actual use case I can’t really give you a better example. Here is it with a setTimeout as well.
https://jsfiddle.net/rqkejy2z/