mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-11-29 19:03:42 +00:00
Update chrome.js
This commit is contained in:
parent
cca8403b78
commit
91712498ad
|
|
@ -23,9 +23,6 @@ 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",
|
||||||
|
|
@ -68,9 +65,13 @@ 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() {
|
||||||
var FN = SHELL.getPathOfMyDocuments() + "\\UserData_Chrome_" + this.profileName + "\\" + this.profileName;
|
return this.clear();
|
||||||
return FILE.deleteFolder(FN);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.setUserDataDir = function(dirname) {
|
this.setUserDataDir = function(dirname) {
|
||||||
|
|
@ -108,12 +109,7 @@ 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);
|
||||||
|
|
@ -192,17 +188,6 @@ 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);
|
||||||
|
|
||||||
|
|
@ -289,7 +274,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 && this.isPreventProxy != true) {
|
if (this.proxy != null) {
|
||||||
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 + "\"");
|
||||||
}
|
}
|
||||||
|
|
@ -309,7 +294,6 @@ 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);
|
||||||
|
|
@ -473,6 +457,7 @@ var ChromeObject = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.exit = function() {
|
this.exit = function() {
|
||||||
|
console.log("exit");
|
||||||
return this.sendPageRPC("Browser.close", {});
|
return this.sendPageRPC("Browser.close", {});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -1132,20 +1117,6 @@ exports.startWithDebugging = function(url, proxy, profileName, debuggingPort) {
|
||||||
;
|
;
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.startDebug = function(url, proxy, profileName, debuggingPort, isPreventProxy) {
|
exports.VERSIONINFO = "Chrome Web Browser Debugging Interface (chrome.js) version 0.1";
|
||||||
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