summaryrefslogtreecommitdiffstats
path: root/chrome-extension/bg.js
diff options
context:
space:
mode:
authorThibaut Horel <thibaut.horel@gmail.com>2014-07-10 23:10:27 -0400
committerThibaut Horel <thibaut.horel@gmail.com>2014-07-10 23:10:27 -0400
commit78b5f6a8b869de9a15352ab35d5c40e440a3c141 (patch)
treea15dd9b92a22e302a4be639c9198ebb07ff78166 /chrome-extension/bg.js
parent7adefa273b5d04c8e499c1be59081d35722baf65 (diff)
downloadtracker-78b5f6a8b869de9a15352ab35d5c40e440a3c141.tar.gz
[Chrome extension] Add option handling
Diffstat (limited to 'chrome-extension/bg.js')
-rw-r--r--chrome-extension/bg.js16
1 files changed, 14 insertions, 2 deletions
diff --git a/chrome-extension/bg.js b/chrome-extension/bg.js
index 8a74e89..f0cd265 100644
--- a/chrome-extension/bg.js
+++ b/chrome-extension/bg.js
@@ -1,10 +1,20 @@
+var options = {};
+
+chrome.storage.local.get({callback: 'http://localhost:8080', key: 'chrome'}, function(o) { options = o; });
+
+chrome.storage.onChanged.addListener(function(changes) {
+ for (key in changes) {
+ options[key] = changes[key].newValue;
+ }
+});
+
function log(url, title){
var xhr = new XMLHttpRequest();
- xhr.open("POST", "http://localhost:8080");
+ xhr.open("POST", options.callback);
var data = "url=" + encodeURIComponent(url);
data += "&time=" + Date.now();
data += "&title=" + encodeURIComponent(title);
- data += "&key=" + "chromium";
+ data += "&key=" + options.key;
xhr.send(data);
}
@@ -33,3 +43,5 @@ chrome.windows.onFocusChanged.addListener(function (windowId) {
});
}
});
+
+