-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
36 lines (34 loc) · 890 Bytes
/
background.js
File metadata and controls
36 lines (34 loc) · 890 Bytes
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
35
36
var sendPost = function(request) {
// $.post('http://localhost:8082/behavior', request);
$.ajax(
{
type: 'POST',
url: 'http://localhost:8000/behavior',
data: request,
headers: {
'Content-typeZ': 'application/x-www-form-urlencoded'
}
}
)
};
function getCookies(domain, name, callback) {
chrome.cookies.get({"url": domain, "name": name}, function(cookie) {
if(callback) {
callback(cookie.value);
}
});
}
//MESSAGE LISTENER FOR MESSAGES FROM CONTENT SCRIPT
chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
// getCookies("http://localhost:8080/", "connect.sid", function(id) {
// console.log(id);
// });
if (request.activity) {
sendPost(request);
sendResponse( {ack: 'Activity noted'} );
}
else {
sendResponse( {ack: 'Empty activity discarded'});
}
}
);