mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-11 20:21:03 +00:00
Update chrome.js
This commit is contained in:
parent
c04a3753e7
commit
2e3ae53ab7
|
@ -224,6 +224,8 @@ var ChromeObject = function() {
|
|||
return JSON.parse(HTTP.get("http://127.0.0.1:" + this.debuggingPort + "/json"));
|
||||
} catch (e) {
|
||||
console.error("ChromeObject.getPageList() -> " + e.message);
|
||||
sleep(1);
|
||||
return this.getPageList();
|
||||
}
|
||||
} else {
|
||||
console.error("Remote debugging unavailable");
|
||||
|
@ -394,7 +396,7 @@ var ChromeObject = function() {
|
|||
|
||||
this.setTitle = function(title) {
|
||||
if (this.debuggingPort > 0) {
|
||||
for (var i = 0; i < 10; i++) {
|
||||
for (var i = 0; i < 3; i++) {
|
||||
this.evaluate('document.title = "' + title + '"');
|
||||
}
|
||||
}
|
||||
|
@ -432,6 +434,19 @@ var ChromeObject = function() {
|
|||
max = Math.floor(max);
|
||||
return Math.floor(Math.random() * (max - min + 1)) + min;
|
||||
};
|
||||
|
||||
this.checkDebuggingPort = function() {
|
||||
var isChecked = false;
|
||||
|
||||
if (this.debuggingPort > 0) {
|
||||
var result = SHELL.exec("netstat -ano | findstr :" + this.debuggingPort);
|
||||
if (result.indexOf(":" + this.debuggingPort) > -1) {
|
||||
isChecked = true;
|
||||
}
|
||||
}
|
||||
|
||||
return isChecked;
|
||||
};
|
||||
|
||||
this.create();
|
||||
};
|
||||
|
@ -450,11 +465,18 @@ exports.start = function(url, proxyPort, profileName, userDataDir, installedDir)
|
|||
};
|
||||
|
||||
exports.startWithDebugging = function(url, proxy, profileName, debuggingPort) {
|
||||
return (new ChromeObject())
|
||||
.setProxy(proxy)
|
||||
.setProfile(profileName, null)
|
||||
.setUserDataDir(null)
|
||||
.setDebuggingPort(debuggingPort)
|
||||
.open(url)
|
||||
var isChecked = false;
|
||||
var browser = (new ChromeObject())
|
||||
.setProxy(proxy)
|
||||
.setProfile(profileName, null)
|
||||
.setUserDataDir(null)
|
||||
.setDebuggingPort(debuggingPort)
|
||||
;
|
||||
|
||||
while (!isChecked) {
|
||||
browser.open(url);
|
||||
isChecked = browser.checkDebuggingPort();
|
||||
}
|
||||
|
||||
return browser;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user