aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.rst26
-rw-r--r--chrome-extension/bg.js13
-rw-r--r--firefox-addon/lib/main.js19
3 files changed, 33 insertions, 25 deletions
diff --git a/README.rst b/README.rst
index e87ad9b..150cd4e 100644
--- a/README.rst
+++ b/README.rst
@@ -30,15 +30,17 @@ one the following events occur:
The body of the POST request is a JSON object containing the following keys:
-========= ===========
-Key Name Description
-========= ===========
-``title`` Title of the webpage (typically the content of the ``<title>`` tag)
-``url`` URL of the webpage
-``time`` Time at which the event occurred. Number of milliseconds elapsed
- since 1 January 1970 00:00:00 UTC
-``key`` A key identifying the browser sending the request
-========= ===========
+=========== ===========
+Key Name Description
+=========== ===========
+``title`` Title of the webpage (typically the content of the ``<title>`` tag)
+``url`` URL of the webpage
+``time`` Time at which the event occurred. Number of milliseconds elapsed
+ since 1 January 1970 00:00:00 UTC
+``key`` A key identifying the browser sending the request
+``favicon`` The URL of the webpage's favicon (or ``null`` when there is no
+ favicon)
+=========== ===========
For window deactivation events, all the keys except for the ``time`` key are
set to ``null``.
@@ -48,10 +50,10 @@ Example of request content:
.. code:: json
{"url":"https://github.com/Thibauth/browsing-activity-tracker",
- "time":1405354714678,
+ "time":1405458411242,
"title":"Thibauth/browsing-activity-tracker",
- "key":"firefox"}
-
+ "key":"firefox",
+ "favicon":"https://assets-cdn.github.com/favicon.ico"}
Also note that the window activation and deactivation events are triggered by
your window manager and vary depending on your configuration. For example, in
diff --git a/chrome-extension/bg.js b/chrome-extension/bg.js
index 208b7bd..2157d58 100644
--- a/chrome-extension/bg.js
+++ b/chrome-extension/bg.js
@@ -8,10 +8,11 @@ chrome.storage.onChanged.addListener(function(changes) {
}
});
-function log(url, title){
+function log(url, title, favicon){
var data = JSON.stringify({
url: url, time: Date.now(),
- title: title, key: prefs.key
+ title: title, key: prefs.key,
+ favicon: favicon
});
var xhr = new XMLHttpRequest();
xhr.open("POST", prefs.callback);
@@ -23,7 +24,7 @@ chrome.tabs.onActivated.addListener(function (activeInfo) {
if (tab.status === "complete" && tab.active) {
chrome.windows.get(tab.windowId, {populate: false}, function(window) {
if (window.focused) {
- log(tab.url, tab.title);
+ log(tab.url, tab.title, tab.favIconUrl || null);
}
});
}
@@ -34,7 +35,7 @@ chrome.tabs.onUpdated.addListener(function (tabId, changeInfo, tab) {
if (changeInfo.status === "complete" && tab.active) {
chrome.windows.get(tab.windowId, {populate: false}, function(window) {
if (window.focused) {
- log(tab.url, tab.title);
+ log(tab.url, tab.title, tab.favIconUrl || null);
}
});
}
@@ -42,13 +43,13 @@ chrome.tabs.onUpdated.addListener(function (tabId, changeInfo, tab) {
chrome.windows.onFocusChanged.addListener(function (windowId) {
if (windowId == chrome.windows.WINDOW_ID_NONE) {
- log(null, null);
+ log(null, null, null);
} else {
chrome.windows.get(windowId, {populate: true}, function(window) {
if (window.focused) {
chrome.tabs.query({active: true, windowId: windowId}, function (tabs) {
if (tabs[0].status === "complete") {
- log(tabs[0].url, tabs[0].title);
+ log(tabs[0].url, tabs[0].title, tabs[0].favIconUrl || null);
}
});
}
diff --git a/firefox-addon/lib/main.js b/firefox-addon/lib/main.js
index 285397b..f0926c4 100644
--- a/firefox-addon/lib/main.js
+++ b/firefox-addon/lib/main.js
@@ -1,15 +1,17 @@
var windows = require("sdk/windows").browserWindows;
var tabs = require("sdk/tabs");
-var Request = require("sdk/request").Request;
-var prefs = require("sdk/simple-prefs").prefs;
-var XMLHttpRequest = require("sdk/net/xhr").XMLHttpRequest;
+var { Request } = require("sdk/request");
+var { prefs } = require("sdk/simple-prefs");
+var { XMLHttpRequest } = require("sdk/net/xhr");
+var { getFavicon } = require("sdk/places/favicon");
var previous_window = null;
-function log(url, title){
+function log(url, title, favicon){
var data = JSON.stringify({
url: url, time: Date.now(),
- title: title, key: prefs.key
+ title: title, key: prefs.key,
+ favicon: favicon
});
var xhr = new XMLHttpRequest();
xhr.open("POST", prefs.callback);
@@ -18,13 +20,16 @@ function log(url, title){
function logTab(tab) {
if (tab.id === tabs.activeTab.id) {
- log(tab.url, tab.title);
+ getFavicon(tab, function(favicon) {
+ log(tab.url, tab.title, favicon);
+ });
}
}
tabs.on("activate", function () { logTab(tabs.activeTab) });
tabs.on("pageshow", logTab );
+
windows.on("activate", function (window) {
if (previous_window != window) {
previous_window = window;
@@ -33,4 +38,4 @@ windows.on("activate", function (window) {
logTab(tabs.activeTab) ;
});
-windows.on("deactivate", function (window) { log(null, null) });
+windows.on("deactivate", function (window) { log(null, null, null) });