I’ve been looking around for this but cant get my finger on it for a while now.
I have a javascript running on a website that is generating messages with a particular string. I want to create an app that checks to see if this particular string exists on the element the javascript is generating. How can I do this? I’ve built a script that reads the webpage HTML and can check for a string within the HTML itself but cannot do this with the javascript since the message elements are being generated after a second or so and are not in the webpage source code.
You can see an example of the javascript elements I need to work with on openbook.etoro.com
I have no relation or connection with this company, its just the best example I could find.
In this website there a script generating messages about what trades some people traded with some info about how long ago (the string I’m looking for).
How can this be done?
There are two ways that come to mind. One figure out what function or event is loading the new elements and then run your function afterwards. Or use
setInterval(function(){checkForString()},5000);which would run every five seconds.