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
22fa86f7ba
commit
6d4d224e86
|
@ -53,10 +53,22 @@ var ChromeObject = function() {
|
|||
this.isPreventEvaluate = false;
|
||||
|
||||
this.create = function() {
|
||||
this.oAutoIt = AutoItX.create().getInterface();
|
||||
try {
|
||||
this.oAutoIt = AutoItX.create().getInterface();
|
||||
} catch (e) {
|
||||
console.warn("AutoItX is disabled");
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
this.callAutoIt = function(FN, args) {
|
||||
if (this.oAutoIt != null) {
|
||||
this.oAutoIt[FN].apply(args);
|
||||
} else {
|
||||
console.warn("AutoItX is disabled");
|
||||
}
|
||||
};
|
||||
|
||||
this.setIsPreventEvaluate = function(flag) {
|
||||
this.isPreventEvaluate = flag;
|
||||
};
|
||||
|
@ -505,7 +517,7 @@ var ChromeObject = function() {
|
|||
|
||||
this.terminate = function() {
|
||||
try {
|
||||
this.oAutoIt.WinKill(this.getTitle());
|
||||
this.callAutoIt("WinKill", [this.getTitle()]);
|
||||
} catch (e) {
|
||||
console.error("ChromeObject.terminate() ->", e.message);
|
||||
}
|
||||
|
@ -521,13 +533,13 @@ var ChromeObject = function() {
|
|||
this.setPageId(null);
|
||||
}
|
||||
|
||||
// calling _focus()
|
||||
// calling _focus()
|
||||
title = this._focus();
|
||||
|
||||
// find window by title
|
||||
var pageList = this.getPageList();
|
||||
if (pageList.length > 0) {
|
||||
this.oAutoIt.WinActivate(title);
|
||||
this.callAutoIt("WinActivate", [title]);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("ChromeObject._focus() ->", e.message);
|
||||
|
@ -602,7 +614,7 @@ 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(title, "", x, y, w, h);
|
||||
this.callAutoIt("WinMove", [title, "", x, y, w, h]);
|
||||
|
||||
// blur
|
||||
this.blur();
|
||||
|
@ -618,7 +630,7 @@ var ChromeObject = function() {
|
|||
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);
|
||||
this.callAutoIt("WinMove", [title, "", x, y, w, h]);
|
||||
|
||||
// blur
|
||||
this.blur();
|
||||
|
@ -628,8 +640,8 @@ var ChromeObject = function() {
|
|||
if (this.debuggingPort > 0) {
|
||||
try {
|
||||
var pos = this.getScreenPosition();
|
||||
this.oAutoIt.MouseMove(pos.x + 100, pos.y + 100);
|
||||
this.oAutoIt.MouseWheel("down", times);
|
||||
this.callAutoIt("MouseMove" [pos.x + 100, pos.y + 100]);
|
||||
this.callAutoIt("MouseWheel", ["down", times]);
|
||||
} catch (e) {
|
||||
console.error("ChromeObject.downMouseWheel() ->", e.message);
|
||||
}
|
||||
|
@ -640,8 +652,8 @@ var ChromeObject = function() {
|
|||
if (this.debuggingPort > 0) {
|
||||
try {
|
||||
var pos = this.getScreenPosition();
|
||||
this.oAutoIt.MouseMove(pos.x + 100, pos.y + 100);
|
||||
this.oAutoIt.MouseWheel("up", times);
|
||||
this.callAutoIt("MouseMove", [pos.x + 100, pos.y + 100]);
|
||||
this.callAutoIt("MouseWheel", ["up", times]);
|
||||
} catch (e) {
|
||||
console.error("ChromeObject.upMouseWheel() ->", e.message);
|
||||
}
|
||||
|
@ -1068,7 +1080,7 @@ var ChromeObject = function() {
|
|||
};
|
||||
|
||||
this.sendSpaceKey = function() {
|
||||
this.oAutoIt.Send("{SPACE}");
|
||||
this.callAutoIt("Send", ["{SPACE}"]);
|
||||
};
|
||||
|
||||
this.setValue = function(selector, value, repeat, searchIndex) {
|
||||
|
@ -1133,7 +1145,11 @@ var ChromeObject = function() {
|
|||
this.__escape = function(value) {
|
||||
return 'decodeURIComponent("' + encodeURIComponent(value) + '")';
|
||||
};
|
||||
|
||||
|
||||
this.prompt = function(s) {
|
||||
return this.getEvaluatedValue('prompt("' + s + '")');
|
||||
};
|
||||
|
||||
this.setVendor = function(vendor) {
|
||||
var vendor = vendor.toLowerCase();
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user