Update chrome.js

This commit is contained in:
Namhyeon Go 2022-04-05 03:10:23 +09:00 committed by GitHub
parent dc93f4b987
commit e1df66f6f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -53,9 +53,21 @@ var ChromeObject = function(interfaces) {
this.frameIndex = -1;
this.isPreventEvaluate = false;
this.isAppMode = true;
this.baseScreenX = 0;
this.baseScreenY = 0;
this.create = function() {
this.oAutoIt = AutoIt.create();
if (!this.isAppMode) {
this.baseScreenX = 1;
this.baseScreenY = 87;
} else {
this.baseScreenX = 1;
this.baseScreenY = 32;
}
return this;
};
@ -306,6 +318,12 @@ var ChromeObject = function(interfaces) {
// block non-proxyed webrtc traffic
cmd.push("--force-webrtc-ip-handling-policy=disable-non-proxied-udp");
// disable session crashed bubble (
//cmd.push("--disable-session-crashed-bubble");
// enable restore the last session
//cmd.push("--restore-last-session");
// set profile directory
cmd.push("--profile-directory=\"" + this.profileName + "\"");
@ -328,8 +346,14 @@ var ChromeObject = function(interfaces) {
cmd.push("--user-agent=\"" + this.userAgent + "\"");
}
// set URL
// set the URL
if (!this.isAppMode) {
cmd.push("\"" + url + "\"");
} else {
cmd.push("--app=\"" + url + "\"");
}
// build the command line
console.log(cmd.join(" "));
// run
@ -351,14 +375,23 @@ var ChromeObject = function(interfaces) {
if (this.debuggingPort > 0) {
try {
var responseText = HTTP.get("http://127.0.0.1:" + this.debuggingPort + "/json");
//var responseText = HTTP.get("http://127.0.0.1:" + this.debuggingPort + "/json");
//console.log(responseText);
pageList = JSON.parse(responseText);
//pageList = JSON.parse(responseText);
var pageList = HTTP.create("CURL")
.setDataType("json")
.open("GET", "http://127.0.0.1:" + this.debuggingPort + "/json")
.send()
.responseBody
;
this.pageList = pageList;
return pageList;
} catch (e) {
console.error("ChromeObject.getPageList() ->", e.message);
return this.getPageList();
//return this.getPageList(); // 무한 루프 문제로 주석처리
return pageList; // 바로 넘김
}
} else {
console.error("Remote debugging unavailable");
@ -1167,12 +1200,12 @@ var ChromeObject = function(interfaces) {
};
this.vMouseClick = function(x, y) {
Toolkit.sendClick(this.pageId.substring(0, 6), x, y, 1);
Toolkit.sendClick(this.pageId.substring(0, 6), this.baseScreenX + x, this.baseScreenY + y, 1);
};
this.mouseClick = function(x, y) {
var screenPosition = this.getScreenPosition();
this.oAutoIt.callFunction("MouseMove", [screenPosition.x + x, screenPosition.y + y]);
this.oAutoIt.callFunction("MouseMove", [screenPosition.x + this.baseScreenX + x, screenPosition.y + this.baseScreenY + y]);
this.oAutoIt.callFunction("MouseClick", ["left"]);
};