Skip to content

Commit 11aaf3a

Browse files
committed
Merge pull request #32 from denisu/patch-2
Ability to set a custom user agent and README.md update
2 parents 171ae90 + 426fb47 commit 11aaf3a

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,10 @@ $.visit('https://www.google.com', function(){
241241

242242
- site: (string, default='') - A base url for the site so that all other 'visit' calls could be relative.
243243
- addJQuery: (boolean, default=TRUE) - TRUE if you need to add jQuery to the page you are visiting, FALSE if the page already adds jQuery.
244-
- jQuery: (string, default='http://code.jquery.com/jquery-1.9.1.min.js') - The CDN url of the jQuery to add to the page if addJQuery is set to TRUE.
244+
- jQuery: (string, default='http://code.jquery.com/jquery-1.11.1.min.js') - The CDN url of the jQuery to add to the page if addJQuery is set to TRUE.
245+
- width: (int, default=1920) - The width of the viewport
246+
- height: (int, default=1080) - The height of the viewport
247+
- userAgent: (string, defaults to phantoms agent) - Set a custom user agent
245248

246249
```javascript
247250
var $ = require('jquerygo');

lib/jquery.go.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,14 @@ var jQuery = _.extend(function(selector, context) {
365365
});
366366
}
367367

368+
// Set a custom user agent if it hasn't already been set.
369+
if (self.config.userAgent && !self.userAgentSet) {
370+
self.userAgentSet = true;
371+
page.set('settings.userAgent', self.config.userAgent, function (result) {
372+
self.debug("Useragent set to: " + result);
373+
});
374+
}
375+
368376
// Open the page.
369377
self.debug('Navigating to ' + self.config.site + url);
370378
page.open(self.config.site + url, function(status) {

0 commit comments

Comments
 (0)