mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-13 21:21:03 +00:00
Update chrome.js
This commit is contained in:
parent
91712498ad
commit
5e5f088dbb
|
@ -23,6 +23,9 @@ var ChromeObject = function() {
|
||||||
this.installedDir = "Chrome";
|
this.installedDir = "Chrome";
|
||||||
this.profileName = "Default";
|
this.profileName = "Default";
|
||||||
this.userDataDir = null;
|
this.userDataDir = null;
|
||||||
|
|
||||||
|
// proxy
|
||||||
|
this.isPreventProxy = false;
|
||||||
this.proxy = {
|
this.proxy = {
|
||||||
"protocol": "socks5",
|
"protocol": "socks5",
|
||||||
"host": "127.0.0.1",
|
"host": "127.0.0.1",
|
||||||
|
@ -65,13 +68,9 @@ var ChromeObject = function() {
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.clear = function() {
|
|
||||||
console.log("clear");
|
|
||||||
return FILE.deleteFolder(SHELL.getPathOfMyDocuments() + "\\UserData_Chrome_" + this.profileName + "\\" + this.profileName);
|
|
||||||
};
|
|
||||||
|
|
||||||
this.clearProfile = function() {
|
this.clearProfile = function() {
|
||||||
return this.clear();
|
var FN = SHELL.getPathOfMyDocuments() + "\\UserData_Chrome_" + this.profileName + "\\" + this.profileName;
|
||||||
|
return FILE.deleteFolder(FN);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.setUserDataDir = function(dirname) {
|
this.setUserDataDir = function(dirname) {
|
||||||
|
@ -109,7 +108,12 @@ var ChromeObject = function() {
|
||||||
this.proxy.port = port;
|
this.proxy.port = port;
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.setIsPreventProxy = function(flag) {
|
||||||
|
this.isPreventProxy = flag;
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
this.setDebuggingPort = function(port) {
|
this.setDebuggingPort = function(port) {
|
||||||
this.debuggingPort = port;
|
this.debuggingPort = port;
|
||||||
console.log("Enabled debugging port:", port);
|
console.log("Enabled debugging port:", port);
|
||||||
|
@ -188,6 +192,17 @@ var ChromeObject = function() {
|
||||||
return this;
|
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.open = function(url) {
|
||||||
this.setProfile(this.profileName, this.installedDir);
|
this.setProfile(this.profileName, this.installedDir);
|
||||||
|
|
||||||
|
@ -274,7 +289,7 @@ var ChromeObject = function() {
|
||||||
cmd.push("--profile-directory=\"" + this.profileName + "\"");
|
cmd.push("--profile-directory=\"" + this.profileName + "\"");
|
||||||
|
|
||||||
// set proxy configuration
|
// set proxy configuration
|
||||||
if (this.proxy != null) {
|
if (this.proxy != null && this.isPreventProxy != true) {
|
||||||
console.log("Enabled proxy server:", this.proxy.protocol + "://" + this.proxy.host + ":" + this.proxy.port);
|
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 + "\"");
|
cmd.push("--proxy-server=\"" + this.proxy.protocol + "://" + this.proxy.host + ":" + this.proxy.port + "\"");
|
||||||
}
|
}
|
||||||
|
@ -294,6 +309,7 @@ var ChromeObject = function() {
|
||||||
|
|
||||||
// set URL
|
// set URL
|
||||||
cmd.push("\"" + url + "\"");
|
cmd.push("\"" + url + "\"");
|
||||||
|
console.log(cmd.join(" "));
|
||||||
|
|
||||||
// run
|
// run
|
||||||
shell.runAs(this.binPath, cmd);
|
shell.runAs(this.binPath, cmd);
|
||||||
|
@ -457,7 +473,6 @@ var ChromeObject = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.exit = function() {
|
this.exit = function() {
|
||||||
console.log("exit");
|
|
||||||
return this.sendPageRPC("Browser.close", {});
|
return this.sendPageRPC("Browser.close", {});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1117,6 +1132,20 @@ exports.startWithDebugging = function(url, proxy, profileName, debuggingPort) {
|
||||||
;
|
;
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.VERSIONINFO = "Chrome Web Browser Debugging Interface (chrome.js) version 0.1";
|
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.global = global;
|
exports.global = global;
|
||||||
exports.require = global.require;
|
exports.require = global.require;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user