aboutsummaryrefslogtreecommitdiffstats
path: root/chrome-extension
diff options
context:
space:
mode:
authorThibaut Horel <thibaut.horel@gmail.com>2014-07-13 12:08:12 -0400
committerThibaut Horel <thibaut.horel@gmail.com>2014-07-13 12:08:12 -0400
commit9488cab6fe509913b9d4819804a104e1371ffcc3 (patch)
tree763427507e6b5cf0519dcc5bc636e0c4c508d841 /chrome-extension
parent839b1245a2137fc3c4474b4ed8d04590b4245611 (diff)
downloadbrowsing-activity-tracker-9488cab6fe509913b9d4819804a104e1371ffcc3.tar.gz
Send data as JSON instead of x-www-form-urlencoded
Diffstat (limited to 'chrome-extension')
-rw-r--r--chrome-extension/bg.js16
1 files changed, 8 insertions, 8 deletions
diff --git a/chrome-extension/bg.js b/chrome-extension/bg.js
index f0cd265..4b39611 100644
--- a/chrome-extension/bg.js
+++ b/chrome-extension/bg.js
@@ -1,20 +1,20 @@
-var options = {};
+var prefs = {};
-chrome.storage.local.get({callback: 'http://localhost:8080', key: 'chrome'}, function(o) { options = o; });
+chrome.storage.local.get({callback: 'http://localhost:8080', key: 'chrome'}, function(o) { prefs = o; });
chrome.storage.onChanged.addListener(function(changes) {
for (key in changes) {
- options[key] = changes[key].newValue;
+ prefs[key] = changes[key].newValue;
}
});
function log(url, title){
+ var data = JSON.stringify({
+ url: url, time: Date.now(),
+ title: title, key: prefs.key
+ });
var xhr = new XMLHttpRequest();
- xhr.open("POST", options.callback);
- var data = "url=" + encodeURIComponent(url);
- data += "&time=" + Date.now();
- data += "&title=" + encodeURIComponent(title);
- data += "&key=" + options.key;
+ xhr.open("POST", prefs.callback);
xhr.send(data);
}