More accurate blocking stats.
This commit is contained in:
parent
d48d7031c0
commit
170cd3508c
|
@ -141,12 +141,17 @@ var RequestGuard = (() => {
|
||||||
_updateTabNow(tabId) {
|
_updateTabNow(tabId) {
|
||||||
this._pendingTabs.delete(tabId);
|
this._pendingTabs.delete(tabId);
|
||||||
let records = this.map.get(tabId) || this.initTab(tabId);
|
let records = this.map.get(tabId) || this.initTab(tabId);
|
||||||
|
|
||||||
let {allowed, blocked, noscriptFrames} = records;
|
let {allowed, blocked, noscriptFrames} = records;
|
||||||
let topAllowed = !(noscriptFrames && noscriptFrames[0]);
|
let topAllowed = !(noscriptFrames && noscriptFrames[0]);
|
||||||
let numAllowed = 0, numBlocked = 0, sum = 0;
|
let numAllowed = 0, numBlocked = 0, sum = 0;
|
||||||
let report = this.types.map(t => {
|
let report = this.types.map(t => {
|
||||||
let a = allowed[t] && allowed[t].length || 0, b = blocked[t] && blocked[t].length || 0, s = a + b;
|
let a = allowed[t] && allowed[t].length || 0,
|
||||||
numAllowed+= a, numBlocked += b, sum += s;
|
b = blocked[t] && blocked[t].length || 0,
|
||||||
|
s = a + b;
|
||||||
|
numAllowed += a;
|
||||||
|
numBlocked += b;
|
||||||
|
sum += s;
|
||||||
return s && `<${t === "sub_frame" ? "frame" : t}>: ${b}/${s}`;
|
return s && `<${t === "sub_frame" ? "frame" : t}>: ${b}/${s}`;
|
||||||
}).filter(s => s).join("\n");
|
}).filter(s => s).join("\n");
|
||||||
let enforced = ns.isEnforced(tabId);
|
let enforced = ns.isEnforced(tabId);
|
||||||
|
@ -206,17 +211,26 @@ var RequestGuard = (() => {
|
||||||
let seen = await ns.collectSeen(tabId);
|
let seen = await ns.collectSeen(tabId);
|
||||||
TabStatus.recordAll(tabId, seen);
|
TabStatus.recordAll(tabId, seen);
|
||||||
},
|
},
|
||||||
|
onUpdatedTab(tabId, changeInfo) {
|
||||||
|
if (changeInfo.url) {
|
||||||
|
TabStatus.initTab(tabId);
|
||||||
|
}
|
||||||
|
},
|
||||||
onRemovedTab(tabId) {
|
onRemovedTab(tabId) {
|
||||||
TabStatus.map.delete(tabId);
|
TabStatus.map.delete(tabId);
|
||||||
TabStatus._originsCache.clear();
|
TabStatus._originsCache.clear();
|
||||||
TabStatus._pendingTabs.delete(tabId);
|
TabStatus._pendingTabs.delete(tabId);
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
browser.tabs.onActivated.addListener(TabStatus.onActivatedTab);
|
for (let event of ["Activated", "Updated", "Removed"]) {
|
||||||
browser.tabs.onRemoved.addListener(TabStatus.onRemovedTab);
|
browser.tabs[`on${event}`].addListener(TabStatus[`on${event}Tab`]);
|
||||||
|
}
|
||||||
|
|
||||||
let messageHandler = {
|
let messageHandler = {
|
||||||
async pageshow(message, sender) {
|
async pageshow(message, sender) {
|
||||||
TabStatus.recordAll(sender.tab.id, message.seen);
|
if (sender.frameId === 0) {
|
||||||
|
TabStatus.recordAll(sender.tab.id, message.seen);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
violation({url, type}, sender) {
|
violation({url, type}, sender) {
|
||||||
|
|
Loading…
Reference in New Issue