Inject javascript codes to override the modal dialog functions for PhantomJS browser.
Use custom `click()` method if using PhantomJS.
Working codes for PhantomJS hacks.