mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-11 20:21:03 +00:00
Add files via upload
This commit is contained in:
parent
746fd841d6
commit
341fc4df02
|
@ -260,7 +260,7 @@ var ChromeObject = function() {
|
|||
if (this.debuggingPort > 0) {
|
||||
try {
|
||||
var responseText = HTTP.get("http://127.0.0.1:" + this.debuggingPort + "/json");
|
||||
console.info(responseText);
|
||||
//console.info(responseText);
|
||||
pageList = JSON.parse(responseText);
|
||||
this.pageList = pageList;
|
||||
return pageList;
|
||||
|
@ -275,10 +275,9 @@ var ChromeObject = function() {
|
|||
};
|
||||
|
||||
this.getPageById = function(id) {
|
||||
var pages = this.getPageList().filter(function(x) {
|
||||
return this.getPageList().find(function(x) {
|
||||
return (x.id = id);
|
||||
});
|
||||
return (pages.length > 0 ? pages[0] : null);
|
||||
};
|
||||
|
||||
this.getPagesByUrl = function(url) {
|
||||
|
@ -511,23 +510,50 @@ var ChromeObject = function() {
|
|||
"g": parseInt(pos[4]),
|
||||
"d": parseInt(pos[5])
|
||||
};
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
"x": -1,
|
||||
"y": -1,
|
||||
"a": -1,
|
||||
"b": -1,
|
||||
"g": -1,
|
||||
"d": -1
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
this.getNestedElementPosition = function(selector, subSelector, searchText) {
|
||||
var s = ''
|
||||
+ '(function() {'
|
||||
+ ' var elements = Object.values(document.querySelectorAll("' + selector + '")).filter(function(x) {'
|
||||
+ ' return (x.querySelector("' + subSelector + '").innerText.indexOf(decodeURIComponent("' + encodeURIComponent(searchText) + '")) > -1);'
|
||||
+ ' });'
|
||||
+ ' if (elements.length > 0) {'
|
||||
+ ' var rect = elements[0].getBoundingClientRect();'
|
||||
+ ' return [parseInt(rect.left), parseInt(rect.top), parseInt(rect.x), parseInt(rect.y), parseInt(rect.right), parseInt(rect.bottom)].join(",");'
|
||||
+ ' } else {'
|
||||
+ ' return "";'
|
||||
+ ' }'
|
||||
+ '})()'
|
||||
;
|
||||
var s = '';
|
||||
|
||||
if (searchText.indexOf(':p(') != 0) {
|
||||
s += '(function() {'
|
||||
+ ' var elements = Object.values(document.querySelectorAll("' + selector + '")).filter(function(x) {'
|
||||
+ ' return (x.querySelector("' + subSelector + '").innerText.indexOf(decodeURIComponent("' + encodeURIComponent(searchText) + '")) > -1);'
|
||||
+ ' });'
|
||||
+ ' if (elements.length > 0) {'
|
||||
+ ' var rect = elements[0].getBoundingClientRect();'
|
||||
+ ' return [parseInt(rect.left), parseInt(rect.top), parseInt(rect.x), parseInt(rect.y), parseInt(rect.right), parseInt(rect.bottom)].join(",");'
|
||||
+ ' } else {'
|
||||
+ ' return "";'
|
||||
+ ' }'
|
||||
+ '})()'
|
||||
;
|
||||
} else {
|
||||
var p = parseFloat(searchText.substring(searchText.indexOf('(') + 1, searchText.indexOf(')')));
|
||||
s += '(function() {'
|
||||
+ ' var elements = Object.values(document.querySelectorAll("' + selector + '")).filter(function(x) {'
|
||||
+ ' return (Math.random() < ' + p + ');'
|
||||
+ ' });'
|
||||
+ ' if (elements.length > 0) {'
|
||||
+ ' var rect = elements[0].getBoundingClientRect();'
|
||||
+ ' return [parseInt(rect.left), parseInt(rect.top), parseInt(rect.x), parseInt(rect.y), parseInt(rect.right), parseInt(rect.bottom)].join(",");'
|
||||
+ ' } else {'
|
||||
+ ' return "";'
|
||||
+ ' }'
|
||||
+ '})()'
|
||||
;
|
||||
}
|
||||
|
||||
var result = this.getEvaluatedValue(s);
|
||||
var pos = result.split(',');
|
||||
if (pos.length == 6) {
|
||||
|
@ -539,7 +565,16 @@ var ChromeObject = function() {
|
|||
"g": parseInt(pos[4]),
|
||||
"d": parseInt(pos[5])
|
||||
};
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
"x": -1,
|
||||
"y": -1,
|
||||
"a": -1,
|
||||
"b": -1,
|
||||
"g": -1,
|
||||
"d": -1
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
this.getPageHeight = function() {
|
||||
|
@ -646,9 +681,12 @@ var ChromeObject = function() {
|
|||
this.oAutoIt.Send("{SPACE}");
|
||||
};
|
||||
|
||||
this.setValue = function(selector, value) {
|
||||
var s = encodeURIComponent(value);
|
||||
return this.evaluate('document.querySelector("' + selector + '").value = decodeURIComponent("' + s + '")');
|
||||
this.setValue = function(selector, value, repeat) {
|
||||
var s = encodeURIComponent(value), i = 0;
|
||||
while (i < repeat) {
|
||||
this.evaluate('document.querySelector("' + selector + '").value = decodeURIComponent("' + s + '")');
|
||||
i++;
|
||||
}
|
||||
};
|
||||
|
||||
this.create();
|
||||
|
|
|
@ -363,7 +363,7 @@ exports.post = function(url, data, headers, params) {
|
|||
};
|
||||
|
||||
exports.get = function(url, data, headers) {
|
||||
return (new HTTPObject()).setHeaders(headers).setParameters(data).get(url).responseBody;
|
||||
return (new HTTPObject()).setHeaders(headers).setParameters(data).setUseCache(false).get(url).responseBody;
|
||||
};
|
||||
|
||||
exports.VERSIONINFO = "HTTP Lib (http.js) version 0.2";
|
||||
|
|
|
@ -17,8 +17,24 @@ var ToolkitObject = function() {
|
|||
this.getInterface = function() {
|
||||
return this.interface;
|
||||
};
|
||||
|
||||
this.create();
|
||||
};
|
||||
|
||||
var Toolkit = new ToolkitObject();
|
||||
|
||||
exports.create = function() {
|
||||
return new ToolkitObject();
|
||||
};
|
||||
|
||||
exports.getInterface = function() {
|
||||
return Toolkit.getInterface();
|
||||
};
|
||||
|
||||
exports.sendClick = function(wName, x, y, repeat) {
|
||||
var i = 0;
|
||||
while (i < repeat) {
|
||||
Toolkit.getInterface().SendClick(wName, x, y);
|
||||
i++;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user