Index: lib/devtools.js |
diff --git a/lib/devtools.js b/lib/devtools.js |
index d4a6e7b9039d4fde52a158c91bb992f8decc0a9c..c094890e436fcd5e8b4522e8062e92469eee8032 100644 |
--- a/lib/devtools.js |
+++ b/lib/devtools.js |
@@ -44,7 +44,7 @@ function hasPanels() |
function getActivePanel(page) |
{ |
let panel = panels[page.id]; |
- if(panel && !panel.reload && !panel.reloading) |
+ if (panel && !panel.reload && !panel.reloading) |
return panel; |
return null; |
} |
@@ -71,7 +71,7 @@ function getFilterInfo(filter) |
return { |
text: filter.text, |
whitelisted: filter instanceof WhitelistFilter, |
- userDefined: userDefined, |
+ userDefined, |
subscription: subscriptionTitle |
}; |
} |
@@ -79,13 +79,16 @@ function getFilterInfo(filter) |
function hasRecord(panel, request, filter) |
{ |
return panel.records.some(record => |
- record.request.url == request.url && |
+ record.request.url == request.url && |
record.request.docDomain == request.docDomain && |
// Ignore partial (e.g. ELEMHIDE) whitelisting if there is already |
// a DOCUMENT exception which disables all means of blocking. |
- (record.request.type == "DOCUMENT" ? nonRequestTypes.indexOf(request.type) != -1 |
- : record.request.type == request.type) && |
+ ( |
+ record.request.type == "DOCUMENT" ? |
+ nonRequestTypes.indexOf(request.type) != -1 : |
+ record.request.type == request.type |
+ ) && |
// Matched element hiding filters don't relate to a particular request, |
// so we also have to match the CSS selector in order to distinguish them. |
@@ -99,14 +102,11 @@ function addRecord(panel, request, filter) |
{ |
panel.port.postMessage({ |
type: "add-record", |
- request: request, |
+ request, |
filter: getFilterInfo(filter) |
}); |
- panel.records.push({ |
- request: request, |
- filter: filter |
- }); |
+ panel.records.push({request, filter}); |
} |
} |
@@ -129,10 +129,12 @@ function matchRequest(request) |
* @param {string} url The URL of the request |
* @param {string} type The request type |
* @param {string} docDomain The IDN-decoded hostname of the document |
- * @param {boolean} thirdParty Whether the origin of the request and document differs |
+ * @param {boolean} thirdParty Whether the origin of the request and |
+ * document differs |
* @param {?string} sitekey The active sitekey if there is any |
* @param {?boolean} specificOnly Whether generic filters should be ignored |
- * @param {?BlockingFilter} filter The matched filter or null if there is no match |
+ * @param {?BlockingFilter} filter The matched filter or null if there is no |
+ * match |
*/ |
exports.logRequest = function(page, url, type, docDomain, |
thirdParty, sitekey, |
@@ -141,16 +143,8 @@ exports.logRequest = function(page, url, type, docDomain, |
let panel = getActivePanel(page); |
if (panel) |
{ |
- let request = { |
- url: url, |
- type: type, |
- docDomain: docDomain, |
- thirdParty: thirdParty, |
- sitekey: sitekey, |
- specificOnly: specificOnly |
- }; |
- |
- addRecord(panel, request, filter); |
+ addRecord(panel, {url, type, docDomain, thirdParty, sitekey, specificOnly}, |
+ filter); |
} |
}; |
@@ -181,11 +175,11 @@ function logHiddenElements(page, selectors, docDomain) |
if (!filter.isActiveOnDomain(docDomain)) |
continue; |
- addRecord(panel, {type: "ELEMHIDE", docDomain: docDomain}, filter); |
+ addRecord(panel, {type: "ELEMHIDE", docDomain}, filter); |
} |
} |
} |
-}; |
+} |
/** |
* Logs a whitelisting filter, that disables (some kind of) |
@@ -193,11 +187,14 @@ function logHiddenElements(page, selectors, docDomain) |
* |
* @param {Page} page The page the whitelisting is active on |
* @param {string} url The url of the whitelisted document |
- * @param {number} typeMask The bit mask of whitelisting types checked for |
- * @param {string} docDomain The IDN-decoded hostname of the parent document |
+ * @param {number} typeMask The bit mask of whitelisting types checked |
+ * for |
+ * @param {string} docDomain The IDN-decoded hostname of the parent |
+ * document |
* @param {WhitelistFilter} filter The matched whitelisting filter |
*/ |
-exports.logWhitelistedDocument = function(page, url, typeMask, docDomain, filter) |
+exports.logWhitelistedDocument = function(page, url, typeMask, docDomain, |
+ filter) |
{ |
let panel = getActivePanel(page); |
if (panel) |
@@ -205,7 +202,7 @@ exports.logWhitelistedDocument = function(page, url, typeMask, docDomain, filter |
for (let type of nonRequestTypes) |
{ |
if (typeMask & filter.contentType & RegExpFilter.typeMap[type]) |
- addRecord(panel, {url: url, type: type, docDomain: docDomain}, filter); |
+ addRecord(panel, {url, type, docDomain}, filter); |
} |
} |
}; |
@@ -339,9 +336,9 @@ function onSubscriptionAdded(subscription) |
updateFilters(subscription.filters, true); |
} |
-chrome.runtime.onConnect.addListener(port => |
+chrome.runtime.onConnect.addListener(newPort => |
{ |
- let match = port.name.match(/^devtools-(\d+)$/); |
+ let match = newPort.name.match(/^devtools-(\d+)$/); |
if (!match) |
return; |
@@ -351,7 +348,7 @@ chrome.runtime.onConnect.addListener(port => |
chrome.webRequest.onBeforeRequest.addListener( |
localOnBeforeRequest, |
{ |
- urls: ["<all_urls>"], |
+ urls: ["<all_urls>"], |
types: ["main_frame"], |
tabId: inspectedTabId |
} |
@@ -365,7 +362,7 @@ chrome.runtime.onConnect.addListener(port => |
FilterNotifier.on("subscription.added", onSubscriptionAdded); |
} |
- port.onDisconnect.addListener(() => |
+ newPort.onDisconnect.addListener(() => |
{ |
delete panels[inspectedTabId]; |
chrome.webRequest.onBeforeRequest.removeListener(localOnBeforeRequest); |
@@ -379,7 +376,7 @@ chrome.runtime.onConnect.addListener(port => |
} |
}); |
- panels[inspectedTabId] = {port: port, records: []}; |
+ panels[inspectedTabId] = {port: newPort, records: []}; |
}); |
port.on("devtools.traceElemHide", (message, sender) => |