mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-06-18 02:59:04 +00:00
Update chrome.js
This commit is contained in:
parent
cc36fffbd9
commit
1e95b79056
|
@ -266,7 +266,6 @@ var ChromeObject = function() {
|
|||
try {
|
||||
var responseText = HTTP.get("http://127.0.0.1:" + this.debuggingPort + "/json");
|
||||
//console.info(responseText);
|
||||
console.log(responseText);
|
||||
pageList = JSON.parse(responseText);
|
||||
this.pageList = pageList;
|
||||
return pageList;
|
||||
|
@ -448,7 +447,7 @@ var ChromeObject = function() {
|
|||
};
|
||||
|
||||
this.autoAdjustByScreen = function(sX, sY, divX, divY) {
|
||||
// catch focus
|
||||
// focus
|
||||
var title = this.focus();
|
||||
sleep(300);
|
||||
|
||||
|
@ -461,7 +460,7 @@ var ChromeObject = function() {
|
|||
var h = this.getRandomInt(bY, sY - bY);
|
||||
this.oAutoIt.WinMove(title, "", x, y, w, h);
|
||||
|
||||
// release focus
|
||||
// blur
|
||||
this.blur();
|
||||
};
|
||||
|
||||
|
@ -477,14 +476,10 @@ var ChromeObject = function() {
|
|||
var y = this.getRandomInt(0, (sY - h < 0 ? parseInt(sY * 0.2) : (sY - h)));
|
||||
this.oAutoIt.WinMove(title, "", x, y, w, h);
|
||||
|
||||
// release focus
|
||||
// blur
|
||||
this.blur();
|
||||
};
|
||||
|
||||
this.blur = function() {
|
||||
return this.evaluate("window.blur()");
|
||||
};
|
||||
|
||||
this.downMouseWheel = function(times) {
|
||||
if (this.debuggingPort > 0) {
|
||||
try {
|
||||
|
@ -536,7 +531,7 @@ var ChromeObject = function() {
|
|||
};
|
||||
|
||||
this.getElementPosition = function(selector) {
|
||||
var result = this.getEvaluatedValue('(function() { var rect = document.querySelector("' + selector + '").getBoundingClientRect(); return [parseInt(rect.left), parseInt(rect.top), parseInt(rect.x), parseInt(rect.y), parseInt(rect.right), parseInt(rect.bottom)].join(","); })();');
|
||||
var result = this.getEvaluatedValue('(function() { var rect = document.querySelector("' + selector + '").getBoundingClientRect(); return [parseInt(rect.left), parseInt(rect.top), parseInt(rect.x), parseInt(rect.y), parseInt(rect.width), parseInt(rect.height)].join(","); })();');
|
||||
var pos = result.split(',');
|
||||
if (pos.length == 6) {
|
||||
return {
|
||||
|
@ -544,8 +539,8 @@ var ChromeObject = function() {
|
|||
"y": parseInt(pos[1]),
|
||||
"a": parseInt(pos[2]),
|
||||
"b": parseInt(pos[3]),
|
||||
"g": parseInt(pos[4]),
|
||||
"d": parseInt(pos[5])
|
||||
"w": parseInt(pos[4]),
|
||||
"h": parseInt(pos[5])
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
|
@ -839,7 +834,8 @@ var ChromeObject = function() {
|
|||
};
|
||||
|
||||
this.reload = function() {
|
||||
return this.sendPageRPC("Page.reload", {});
|
||||
//return this.sendPageRPC("Page.reload", {});
|
||||
return this.evaluate("window.reload()");
|
||||
};
|
||||
|
||||
this.hasClass = function(seletctor, className) {
|
||||
|
@ -863,21 +859,34 @@ var ChromeObject = function() {
|
|||
this.oAutoIt.Send("{SPACE}");
|
||||
};
|
||||
|
||||
this.setValue = function(selector, value, searchIndex) {
|
||||
var searchIndex = (typeof searchIndex !== "undefined" ? searchIndex : 0);
|
||||
var s = encodeURIComponent(value);
|
||||
this.setValue = function(selector, value, repeat, searchIndex) {
|
||||
var s = encodeURIComponent(value),
|
||||
i = 0,
|
||||
searchIndex = (typeof searchIndex !== "undefined" ? searchIndex : 0)
|
||||
;
|
||||
|
||||
while (i < repeat) {
|
||||
if (searchIndex > 0) {
|
||||
this.evaluate('Object.values(document.querySelectorAll("' + selector + '"))[' + searchIndex + '].value = decodeURIComponent("' + s + '");');
|
||||
} else {
|
||||
this.evaluate('document.querySelector("' + selector + '").value = decodeURIComponent("' + s + '")');
|
||||
}
|
||||
i++;
|
||||
}
|
||||
};
|
||||
|
||||
this.getText = function(selector) {
|
||||
return this.getEvaluatedValue('document.querySelector("' + selector + '").innerText');
|
||||
};
|
||||
|
||||
this.traceMouseClick = function() {
|
||||
return this.evaluate('window.addEventListener("click",function(e){var t=e.clientX,n=e.clientY,l=document.createElement("div");l.style.position="absolute",l.style.width="20px",l.style.height="20px",l.style.backgroundColor="#00ff00",l.style.zIndex=99999,l.style.top=window.pageYOffset+n-10+"px",l.style.left=window.pageXOffset+t-10+"px",document.body.appendChild(l)});');
|
||||
};
|
||||
|
||||
this.getWindowInnerHeight = function() {
|
||||
return this.getEvaluatedValue('window.innerHeight');
|
||||
};
|
||||
|
||||
this.create();
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user