Update chrome.js

This commit is contained in:
Namhyeon Go 2021-08-11 22:18:51 +09:00 committed by GitHub
parent 0522f77dde
commit 44a885788d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -369,6 +369,8 @@ var ChromeObject = function() {
};
this.focus = function() {
var title = "";
if (this.debuggingPort > 0) {
try {
// set page id
@ -379,25 +381,27 @@ 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) {
@ -424,11 +428,9 @@ var ChromeObject = function() {
};
this.autoAdjust = function(sX, sY) {
// get current title
var _title = this.getTitle();
// change webpage title
this.setTitle(this.pageId);
// catch focus
var title = this.focus();
sleep(300);
// adjust window position and size
var bX = Math.floor(sX / 6);
@ -437,14 +439,10 @@ var ChromeObject = function() {
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);
};
this.blur = function() {
return this.evaluate("window.blur()");
// release focus
this.blur();
};
this.downMouseWheel = function(times) {