Update chrome.js

This commit is contained in:
Namhyeon Go 2021-08-17 00:14:01 +09:00 committed by GitHub
parent 0f5feece79
commit 0cd8f24182
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -362,13 +362,15 @@ var ChromeObject = function() {
this.terminate = function() {
try {
this.oAutoIt.WinKill(this.title);
this.oAutoIt.WinKill(this.getTitle());
} catch (e) {
console.error("ChromeObject.terminate() ->", e.message);
}
};
this.focus = function() {
var title = "";
if (this.debuggingPort > 0) {
try {
// set page id
@ -379,25 +381,28 @@ var ChromeObject = function() {
// get current title
this.title = this.getTitle();
// new title
var _title = this.title + " " + this.pageId.substring(0, 6);
// will be change title
title = this.title + " " + this.pageId.substring(0, 6);
// change webpage title for focusing window
this.setTitle(_title);
this.setTitle(title);
// find window by title
var pageList = this.getPageList();
if (pageList.length > 0) {
this.oAutoIt.WinActivate(_title);
this.oAutoIt.WinActivate(title);
}
} catch (e) {
console.error("ChromeObject._focus() ->", e.message);
}
}
return title;
};
this.blur = function() {
this.setTitle(this.title);
return this.setTitle(this.title);
};
this.getScrollHeight = function(selector) {
@ -423,24 +428,38 @@ var ChromeObject = function() {
}
};
this.autoAdjust = function(sX, sY) {
// get current title
var _title = this.getTitle();
// change webpage title
this.setTitle(this.pageId);
this.autoAdjustByScreen = function(sX, sY, divX, divY) {
// catch focus
var title = this.focus();
sleep(300);
// adjust window position and size
var bX = Math.floor(sX / 6);
var bY = Math.floor(sY / 3);
var bX = Math.floor(sX / divX);
var bY = Math.floor(sY / divY);
var x = this.getRandomInt(0, bX);
var y = this.getRandomInt(0, bY);
var w = this.getRandomInt(bX * 3, sX - bX);
var h = this.getRandomInt(bY, sY - bY);
this.oAutoIt.WinMove(this.pageId, "", x, y, w, h);
this.oAutoIt.WinMove(title, "", x, y, w, h);
// change webpage title to original
this.setTitle(_title);
// release focus
this.blur();
};
this.autoAdjustByWindow = function(sX, sY, w1, w2, h1, h2) {
// catch focus
var title = this.focus();
sleep(300);
// adjust window position and size
var w = this.getRandomInt(w1, w2);
var h = this.getRandomInt(h1, h2);
var x = this.getRandomInt(0, (sX - w < 0 ? parseInt(sX * 0.2) : (sX - w)));
var y = this.getRandomInt(0, (sY - h < 0 ? parseInt(sY * 0.2) : (sY - h)));
this.oAutoIt.WinMove(title, "", x, y, w, h);
// release focus
this.blur();
};
this.blur = function() {