mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-15 14:11:03 +00:00
Update chrome.js
This commit is contained in:
parent
0522f77dde
commit
44a885788d
|
@ -369,6 +369,8 @@ var ChromeObject = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.focus = function() {
|
this.focus = function() {
|
||||||
|
var title = "";
|
||||||
|
|
||||||
if (this.debuggingPort > 0) {
|
if (this.debuggingPort > 0) {
|
||||||
try {
|
try {
|
||||||
// set page id
|
// set page id
|
||||||
|
@ -379,25 +381,27 @@ var ChromeObject = function() {
|
||||||
// get current title
|
// get current title
|
||||||
this.title = this.getTitle();
|
this.title = this.getTitle();
|
||||||
|
|
||||||
// new title
|
// will be change title
|
||||||
var _title = this.title + " " + this.pageId.substring(0, 6);
|
title = this.title + " " + this.pageId.substring(0, 6);
|
||||||
|
|
||||||
// change webpage title for focusing window
|
// change webpage title for focusing window
|
||||||
this.setTitle(_title);
|
this.setTitle(title);
|
||||||
|
|
||||||
// find window by title
|
// find window by title
|
||||||
var pageList = this.getPageList();
|
var pageList = this.getPageList();
|
||||||
if (pageList.length > 0) {
|
if (pageList.length > 0) {
|
||||||
this.oAutoIt.WinActivate(_title);
|
this.oAutoIt.WinActivate(title);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("ChromeObject._focus() ->", e.message);
|
console.error("ChromeObject._focus() ->", e.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return title;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.blur = function() {
|
this.blur = function() {
|
||||||
this.setTitle(this.title);
|
return this.setTitle(this.title);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getScrollHeight = function(selector) {
|
this.getScrollHeight = function(selector) {
|
||||||
|
@ -424,11 +428,9 @@ var ChromeObject = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.autoAdjust = function(sX, sY) {
|
this.autoAdjust = function(sX, sY) {
|
||||||
// get current title
|
// catch focus
|
||||||
var _title = this.getTitle();
|
var title = this.focus();
|
||||||
|
sleep(300);
|
||||||
// change webpage title
|
|
||||||
this.setTitle(this.pageId);
|
|
||||||
|
|
||||||
// adjust window position and size
|
// adjust window position and size
|
||||||
var bX = Math.floor(sX / 6);
|
var bX = Math.floor(sX / 6);
|
||||||
|
@ -437,14 +439,10 @@ var ChromeObject = function() {
|
||||||
var y = this.getRandomInt(0, bY);
|
var y = this.getRandomInt(0, bY);
|
||||||
var w = this.getRandomInt(bX * 3, sX - bX);
|
var w = this.getRandomInt(bX * 3, sX - bX);
|
||||||
var h = this.getRandomInt(bY, sY - bY);
|
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
|
// release focus
|
||||||
this.setTitle(_title);
|
this.blur();
|
||||||
};
|
|
||||||
|
|
||||||
this.blur = function() {
|
|
||||||
return this.evaluate("window.blur()");
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.downMouseWheel = function(times) {
|
this.downMouseWheel = function(times) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user