added web_response
This commit is contained in:
@@ -18,6 +18,9 @@ fplay.event.on("browser_connect", async function(ws){
|
||||
const blanktab = await fplay.close_all_tabs(ws);
|
||||
await fplay.delete_all_containers(ws);
|
||||
|
||||
// only return responses for these data sources
|
||||
fplay.web_response_whitelist(ws, ["main_frame", "xmlhttprequest"]);
|
||||
|
||||
// create container
|
||||
const container = await fplay.container_create(ws);
|
||||
console.log(container);
|
||||
@@ -47,4 +50,14 @@ fplay.event.on("browser_connect", async function(ws){
|
||||
console.log(result);
|
||||
});
|
||||
|
||||
fplay.event.on("web_request", async function(request){
|
||||
|
||||
console.log(request);
|
||||
});
|
||||
|
||||
fplay.event.on("web_response", async function(request){
|
||||
|
||||
|
||||
});
|
||||
|
||||
fplay.init(port, password, timeout);
|
||||
|
||||
@@ -286,6 +286,18 @@ fplay.tab_inject_js = async function(ws, tabid, js, isolated = false){
|
||||
};
|
||||
}
|
||||
|
||||
fplay.web_response_whitelist = async function(ws, sources = ["main_frame", "xmlhttprequest"]){
|
||||
|
||||
var whitelist_status = await fplay.send(ws, "web_response_whitelist", {"list": sources});
|
||||
|
||||
if(typeof whitelist_status.status === "boolean"){
|
||||
|
||||
return whitelist_status.status;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
@@ -471,6 +483,11 @@ fplay.event.on("dom_ready", function(data){
|
||||
promise.resolve(data);
|
||||
}
|
||||
});
|
||||
/*
|
||||
fplay.event.on("web_response", function(data){
|
||||
|
||||
console.log(data);
|
||||
});*/
|
||||
|
||||
fplay.event.on("dom_load_fail", function(data){
|
||||
|
||||
@@ -512,6 +529,12 @@ fplay.wss.on("connection", async function(ws){
|
||||
return;
|
||||
}
|
||||
|
||||
if(msg.action == "web_response"){
|
||||
|
||||
// decode base64 as a buffer
|
||||
msg.data.body = Buffer.from(msg.data.body, "base64");
|
||||
}
|
||||
|
||||
// any other message should be an unsolicited event
|
||||
fplay.event.emit(msg.action, msg.data);
|
||||
});
|
||||
|
||||
39
server/package-lock.json
generated
Normal file
39
server/package-lock.json
generated
Normal file
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"name": "server",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"dependencies": {
|
||||
"http": "^0.0.1-security",
|
||||
"ws": "^8.21.0"
|
||||
}
|
||||
},
|
||||
"node_modules/http": {
|
||||
"version": "0.0.1-security",
|
||||
"resolved": "https://registry.npmjs.org/http/-/http-0.0.1-security.tgz",
|
||||
"integrity": "sha512-RnDvP10Ty9FxqOtPZuxtebw1j4L/WiqNMDtuc1YMH1XQm5TgDRaR1G9u8upL6KD1bXHSp9eSXo/ED+8Q7FAr+g=="
|
||||
},
|
||||
"node_modules/ws": {
|
||||
"version": "8.21.0",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.21.0.tgz",
|
||||
"integrity": "sha512-Vsp28b7DRcimFQvrqu2Wek3z1iYxDCWqHYB8Qsnk/S4RfaCQzPGPyBNuVjJV3cd6UiKtUtp6sNM77gWvzcCH+g==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"bufferutil": "^4.0.1",
|
||||
"utf-8-validate": ">=5.0.2"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"bufferutil": {
|
||||
"optional": true
|
||||
},
|
||||
"utf-8-validate": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
6
server/package.json
Normal file
6
server/package.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"http": "^0.0.1-security",
|
||||
"ws": "^8.21.0"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user