Fixed bug preventing to work on Node.js

```window``` is not defined in Node.js, checking its type instead of it exists is safer and allow to use the plugin from command line.
I'd recommend checking `location` instead and dropping the `window` proxy.