mirror of
https://github.com/vimagick/dockerfiles.git
synced 2025-12-21 21:33:02 +01:00
add position to frameData
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
var webpage = require('webpage');
|
var webpage = require('webpage');
|
||||||
|
var frame = require('./frame');
|
||||||
|
|
||||||
|
|
||||||
function setCookies(page, cookies) {
|
function setCookies(page, cookies) {
|
||||||
@@ -40,22 +41,6 @@ function execScripts(page, scripts, arr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function frameData(page, data) {
|
|
||||||
data.url = page.frameUrl;
|
|
||||||
data.name = page.frameName;
|
|
||||||
data.content = page.frameContent;
|
|
||||||
data.childCount = page.framesCount;
|
|
||||||
data.childFrames = [];
|
|
||||||
for(var i=0; i<data.childCount; i++) {
|
|
||||||
var node = {};
|
|
||||||
data.childFrames.push(node);
|
|
||||||
page.switchToFrame(i);
|
|
||||||
frameData(page, node);
|
|
||||||
page.switchToParentFrame();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function urlopen(req, callback) {
|
function urlopen(req, callback) {
|
||||||
|
|
||||||
var page = webpage.create();
|
var page = webpage.create();
|
||||||
@@ -201,7 +186,7 @@ function urlopen(req, callback) {
|
|||||||
execScripts(page, req.execScripts.postInjected, result.execScriptsOutput.postInjected);
|
execScripts(page, req.execScripts.postInjected, result.execScriptsOutput.postInjected);
|
||||||
|
|
||||||
var fdata = {};
|
var fdata = {};
|
||||||
frameData(page, fdata);
|
frame.frameData(page, fdata);
|
||||||
fdata.content = null;
|
fdata.content = null;
|
||||||
result.frameData = fdata;
|
result.frameData = fdata;
|
||||||
page.switchToMainFrame();
|
page.switchToMainFrame();
|
||||||
|
|||||||
32
webkit/frame.js
Normal file
32
webkit/frame.js
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
|
||||||
|
function frameData(page, data) {
|
||||||
|
data.url = page.frameUrl;
|
||||||
|
data.name = page.frameName;
|
||||||
|
data.content = page.frameContent;
|
||||||
|
data.childCount = page.framesCount;
|
||||||
|
data.childFrames = [];
|
||||||
|
|
||||||
|
var posList = page.evaluate(framePosition);
|
||||||
|
|
||||||
|
for(var i=0; i<data.childCount; i++) {
|
||||||
|
var node = {};
|
||||||
|
node.position = posList[i];
|
||||||
|
data.childFrames.push(node);
|
||||||
|
page.switchToFrame(i);
|
||||||
|
frameData(page, node);
|
||||||
|
page.switchToParentFrame();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function framePosition() {
|
||||||
|
var nodes = document.getElementsByTagName('iframe');
|
||||||
|
var results = [];
|
||||||
|
for(var i=0; i<nodes.length; i++) {
|
||||||
|
var pos = nodes[i].getBoundingClientRect();
|
||||||
|
results.push(pos);
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports.frameData = frameData;
|
||||||
|
|
||||||
Reference in New Issue
Block a user