PhantomJS: injecting a script before any other scripts run

你说的曾经没有我的故事 提交于 2019-11-30 08:04:28

I don't think there's a "proper" way to inject such script other than hooking to events. I've spent half a year working massively with PhantomJs and found no way to inject before all the errors start happening but after the page finished loading.

I would try to go through onInitialized, onLoadStarted, onLoadFinished. Inside the hooks I would call to page.evaluate() which would just modify DOM to have this extra whatever place you like.

I think one of them (the hooks) should give you the right timing you want.

Cheers

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!