Use javaScriptOnDocumentStart to inject a JS script before the document is loaded and use javaScriptOnDocumentEnd to inject a JS script after the document is loaded.