I’m trying to execute JS in the WebView only after the page has rendered. Since it uses react, the default waitForLoad(); method doesn’t really work. However, in my specific use case, there is an attribute that is added/ changed once React has rendered the page ‘data-gr-c-s-loaded=“true”’. So I’m trying to delay the injection of my JS until that attribute could be found in the HTML. How can I approach this?
You could do it like this:
I tried your amazing approach, but I’m having issues returning values scraped from the WebView. The WebView process never ends even after calling the completion() method, and I don’t think my return statement is being respected.
I assume you have debugged it with various calls to
log (even inside the injected script)?
And I also assume you are trying to return the values by passing them to the
It is hard to say what goes wrong without any code… maybe the
completion() call never gets executed? That’s just a wild guess, I don’t know.
How do you pass in parameters to the completion method? If I’m not mistaken I thought it doesn’t receive any parameters.
As the docs state if you pass
asyncparameter, then the value of the last line of the script that is not whitespace will be returned to the Scriptable script
asyncparameter, then the script waits for the call to
completion()and anything passed to it will be returned to the Scriptable script