Patched functions to work on Firefox & PhantomJS besides chrome