Index: messageResponder.js |
=================================================================== |
--- a/messageResponder.js |
+++ b/messageResponder.js |
@@ -25,16 +25,17 @@ |
const {Prefs} = require("prefs"); |
const {Utils} = require("utils"); |
const {FilterStorage} = require("filterStorage"); |
const {FilterNotifier} = require("filterNotifier"); |
const {defaultMatcher} = require("matcher"); |
const {Notification: NotificationStorage} = require("notification"); |
const {getActiveNotification, shouldDisplay, |
notificationClicked} = require("notificationHelper"); |
+ const {HitLogger} = require("hitLogger"); |
const { |
Filter, ActiveFilter, BlockingFilter, RegExpFilter |
} = require("filterClasses"); |
const {Synchronizer} = require("synchronizer"); |
const info = require("info"); |
const { |
@@ -196,16 +197,55 @@ |
} |
if (message.what == "senderId") |
return sender.page.id; |
return info[message.what]; |
}); |
+ port.on("app.listen", (message, sender) => |
+ { |
+ getListenerFilters(sender.page).app = message.filter; |
+ }); |
+ |
+ port.on("app.collectHits", (message, sender) => |
+ { |
+ const logRequest = (log) => |
+ { |
+ let {filter, request} = log; |
+ let subscriptions = []; |
+ if (filter) |
+ { |
+ for (const soubscription of FilterStorage.subscriptions) |
+ { |
+ for (const text of soubscription.filters) |
+ { |
+ if (text == filter.text) |
+ subscriptions.push(soubscription.url); |
+ } |
+ } |
+ filter = convertObject(["text", "subscription"], filter); |
+ } |
+ request = convertObject(["url", "type", "docDomain", "thirdParty"], |
+ request); |
+ sendMessage("app", "devLog", request, filter, subscriptions); |
+ }; |
+ const removeTabListeners = (tabId) => |
+ { |
+ if (tabId == message.tab.id || tabId == sender.page.id) |
+ { |
+ HitLogger.off(message.tab.id, logRequest); |
+ browser.tabs.onRemoved.removeListener(removeTabListeners); |
+ } |
+ }; |
+ HitLogger.on(message.tab.id, logRequest); |
+ browser.tabs.onRemoved.addListener(removeTabListeners); |
+ }); |
+ |
port.on("app.open", (message, sender) => |
{ |
if (message.what == "options") |
{ |
showOptions(() => |
{ |
if (!message.action) |
return; |