-
Notifications
You must be signed in to change notification settings - Fork 2
/
background.js
34 lines (33 loc) · 1.15 KB
/
background.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
var ports = [];
chrome.runtime.onConnect.addListener(function(port) {
if (port.name !== "devtools") return;
ports.push(port);
// Remove port when destroyed (eg when devtools instance is closed)
port.onDisconnect.addListener(function() {
var i = ports.indexOf(port);
if (i !== -1) ports.splice(i, 1);
});
port.onMessage.addListener(function(msg) {
// Received message from devtools. Do something:
//console.log('request to ', msg.request.url);
console.log('response ', msg);
//make ajax request.
//change URL accordingly
servers = [];
servers.push('http://192.168.1.102/echoData');
servers.push('http://192.168.1.128/echoData');
//servers.push('http://10.48.102.3001/echoData'); //Add more servers here
for (index = 0; index < servers.length; index++) {
$.ajax({
type: 'POST', //GET or POST or PUT or DELETE verb
//url:window.serverURl,
url:servers[index],
data:JSON.stringify({"response":msg}) , //Data sent to server
contentType: 'application/json', // content type sent to server
success: function (msg, textStatus, xmlHttp) {
result = msg;
}
});
}
});
});