Listening to the beforeload
event
#13140
Comments
Have you looked at documentation? You can examine and abort any unwanted resource request using onResourceRequested callback http://phantomjs.org/api/webpage/handler/on-resource-requested.html. |
Yes, I saw There doesn't seem to be a way to communicate with the phantom context in a synchronous way (as provided in Safari by |
Are you testing version 2.0? The edition of Webkit in 1.x is very old and buggy. This is probably a matter of needing to hook some events up properly, and we'd be happy to work with you to make that happen, but we're not developing 1.x anymore and we have limited time for development so we might need you to take the lead on coding up the necessary changes. Sorry. |
$ phantomjs -v
2.0.0 My current solution is to preprocess all loaded pages to add a script tag as the first child of the head, which listens to the event and then removes itself immediately. Quite cumbersome, appears to be working, though. It would be great if phantom could do this for me & I'd be happy to help with the implementation. |
OK. I think the way we would expose |
The primary uses for |
If a page already has a http://phantomjs.org/api/webpage/handler/on-initialized.html |
That's how that event works? The documentation suggests it fires at the point where Safari would inject start scripts, when the page was created, but before the HTTP request for the page itself was made (which is what I'm looking for). The current implementation doesn't help, as the first request isn't necessarily a script. Manually inserting a script, as I'm doing it right now, would of course be a solution, although the status quo wouldn't be improved. Phantom seems also to be lacking the ability to inject scripts into frames (eg. iframes), which should probably also be covered by a solution. |
Due to our very limited maintenance capacity (see #14541 for more details), we need to prioritize our development focus on other tasks. Therefore, this issue will be automatically closed. In the future, if we see the need to attend to this issue again, then it will be reopened. Thank you for your contribution! |
Not sure if this is a bug, a feature request or just a question.
I'm trying to identify ads on pages loaded by phantom. In Safari, this is doable using the
beforeload
event, which needs to be injected before the page starts rendering. The event is still present in qtwebkit.I tried to listen to the event at several points in the page's life cycle, don't seem to be able to receive any notifications, though. I would appreciate any help to get this working.
The text was updated successfully, but these errors were encountered: