alexscheelmeyer / node-phantom

bridge to PhantomJS from Node.js
317 stars 117 forks source link

Add support for userAgent #83

Open Osmosis311 opened 10 years ago

Osmosis311 commented 10 years ago

https://github.com/ariya/phantomjs/blob/master/examples/useragent.js

AlexanderYastrebov commented 10 years ago

Vote up! For now one could use this hack:

function setUserAgent(page, ua) {
    page.setFn('EVIL_EVAL', 'page.settings.userAgent = "' + ua + '"');
}

I think API should be more broad to support setting of nested page properties like

page.set('settings.userAgent', ua);

but not only userAgent or any of page.settings