Here is the problem: some script is injecting some HTML5 elements (actually a button with the
#thebutton ID) to the current DOM.
But this is a third party script and I have no control of when this will be injected to the page. I need to click automatically on this button when the button is injected to the DOM. Here is my solution so far.
It's actually working but I'm not sure on how fine this code is. My first guess is that I may use the
clearTimeout() method. Is there anything else I must do?
Here is a simulated jsFiddle of the whole process: https://jsfiddle.net/qxpcj3wm/