Answer the question
In order to leave comments, you need to log in
Automatically click a button on a website when it appears?
There is a site on which the button independently appears. It is necessary that the script automatically clicks on it when it appears and works in the background. And what is the best way to launch it?
Answer the question
In order to leave comments, you need to log in
In general, there is such an API as MutationObserver . It allows you to track changes to certain DOM elements, changes to their attributes, content, and so on. You can hang such a "surveillance" on the parent element, where the button will appear, and when the event in MutationObserver is triggered, look for the button and click on it.
UPD: example
PS: if you have access to the code that adds this element, or at least calls some kind of callback, it's better not to use MutationObserver, because it is slow on its own, and in the wrong hands can lead to serious performance problems.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question