From 3167034b97933251efbf6e288d244d147d679508 Mon Sep 17 00:00:00 2001 From: Mikhail Konovalov Date: Sun, 27 Dec 2015 16:08:06 +0300 Subject: [PATCH] additional options for SteamCommunity constructor --- index.js | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 4fb068b..d145bfb 100644 --- a/index.js +++ b/index.js @@ -11,25 +11,35 @@ module.exports = SteamCommunity; SteamCommunity.SteamID = SteamID; -function SteamCommunity(localAddress) { +function SteamCommunity(options) { + options = options || {}; + this._jar = Request.jar(); this._captchaGid = -1; this.chatState = SteamCommunity.ChatState.Offline; var defaults = { "jar": this._jar, - "timeout": 50000, + "timeout": options.timeout || 50000, "headers": { - "User-Agent": USER_AGENT + "User-Agent": options.userAgent || USER_AGENT } }; - if(localAddress) { - defaults.localAddress = localAddress; + if (typeof options == "string") { + options = { + localAddress: options + }; + } + this._options = options; + + if (options.localAddress) { + defaults.localAddress = options.localAddress; } - this.request = Request.defaults(defaults); - + this.request = options.request || Request.defaults(); + this.request = this.request.defaults(defaults); + // English this._jar.setCookie(Request.cookie('Steam_Language=english'), 'https://steamcommunity.com');