diff --git a/lib/chrome.js b/lib/chrome.js index 7d39f21..2d2976c 100644 --- a/lib/chrome.js +++ b/lib/chrome.js @@ -23,9 +23,6 @@ var ChromeObject = function() { this.installedDir = "Chrome"; this.profileName = "Default"; this.userDataDir = null; - - // proxy - this.isPreventProxy = false; this.proxy = { "protocol": "socks5", "host": "127.0.0.1", @@ -68,9 +65,13 @@ var ChromeObject = function() { return this; }; + this.clear = function() { + console.log("clear"); + return FILE.deleteFolder(SHELL.getPathOfMyDocuments() + "\\UserData_Chrome_" + this.profileName + "\\" + this.profileName); + }; + this.clearProfile = function() { - var FN = SHELL.getPathOfMyDocuments() + "\\UserData_Chrome_" + this.profileName + "\\" + this.profileName; - return FILE.deleteFolder(FN); + return this.clear(); }; this.setUserDataDir = function(dirname) { @@ -108,12 +109,7 @@ var ChromeObject = function() { this.proxy.port = port; return this; }; - - this.setIsPreventProxy = function(flag) { - this.isPreventProxy = flag; - return this; - }; - + this.setDebuggingPort = function(port) { this.debuggingPort = port; console.log("Enabled debugging port:", port); @@ -192,17 +188,6 @@ var ChromeObject = function() { return this; }; - this.addUserAgentsFromFile = function(filename) { - var text = FILE.readFile(filename, "utf-8"); - var lines = text.split(/\r?\n/); - for (var i = 0; i < lines.length; i++) { - if (lines[i].trim() !== "") { - this.userAgents.push(lines[i]); - } - } - return this; - }; - this.open = function(url) { this.setProfile(this.profileName, this.installedDir); @@ -289,7 +274,7 @@ var ChromeObject = function() { cmd.push("--profile-directory=\"" + this.profileName + "\""); // set proxy configuration - if (this.proxy != null && this.isPreventProxy != true) { + if (this.proxy != null) { console.log("Enabled proxy server:", this.proxy.protocol + "://" + this.proxy.host + ":" + this.proxy.port); cmd.push("--proxy-server=\"" + this.proxy.protocol + "://" + this.proxy.host + ":" + this.proxy.port + "\""); } @@ -309,7 +294,6 @@ var ChromeObject = function() { // set URL cmd.push("\"" + url + "\""); - console.log(cmd.join(" ")); // run shell.runAs(this.binPath, cmd); @@ -473,6 +457,7 @@ var ChromeObject = function() { }; this.exit = function() { + console.log("exit"); return this.sendPageRPC("Browser.close", {}); }; @@ -1132,20 +1117,6 @@ exports.startWithDebugging = function(url, proxy, profileName, debuggingPort) { ; }; -exports.startDebug = function(url, proxy, profileName, debuggingPort, isPreventProxy) { - return (new ChromeObject()) - .setProxy(proxy) - .setProfile(profileName, null) - .setUserDataDir(null) - .setDebuggingPort(debuggingPort) - .setIsPreventProxy(isPreventProxy) - .addUserAgentsFromFile("data\\Chrome.txt") - .addUserAgentsFromFile("data\\Edge.txt") - .addUserAgentsFromFile("data\\Safari.txt") - .open(url) - ; -}; - -exports.VERSIONINFO = "Chrome Web Browser Debugging Interface (chrome.js) version 0.2"; +exports.VERSIONINFO = "Chrome Web Browser Debugging Interface (chrome.js) version 0.1"; exports.global = global; exports.require = global.require;