diff --git a/lib/chrome.js b/lib/chrome.js index 7e292d9..db6db60 100644 --- a/lib/chrome.js +++ b/lib/chrome.js @@ -28,7 +28,10 @@ var ChromeObject = function() { "port": 1080 }; this.inPrivate = false; + + // user agent this.userAgent = null; + this.userAgents = []; // dependencies this.oAutoIt = null; @@ -175,6 +178,11 @@ var ChromeObject = function() { return this; }; + this.addUserAgent = function(ua) { + this.userAgents.push(ua); + return this; + }; + this.open = function(url) { this.setProfile(this.profileName, this.installedDir); @@ -269,7 +277,12 @@ var ChromeObject = function() { // set user data directory cmd.push("--user-data-dir=\"" + this.userDataDir + "\""); - // set user agent + // choice user agent + if (this.userAgents.length > 0) { + this.setUserAgent(RAND.one(this.userAgents)); + } + + // set user agent if (this.userAgent != null) { cmd.push("--user-agent=\"" + this.userAgent + "\""); }