Index: lib/requestBlocker.js |
=================================================================== |
--- a/lib/requestBlocker.js |
+++ b/lib/requestBlocker.js |
@@ -25,18 +25,18 @@ |
const {FilterNotifier} = require("filterNotifier"); |
const {Prefs} = require("prefs"); |
const {checkWhitelisted, getKey} = require("whitelisting"); |
const {stringifyURL, extractHostFromFrame, isThirdParty} = require("url"); |
const {port} = require("messaging"); |
const devtools = require("devtools"); |
// Chrome can't distinguish between OBJECT_SUBREQUEST and OBJECT requests. |
-if (!chrome.webRequest.ResourceType || |
- !("OBJECT_SUBREQUEST" in chrome.webRequest.ResourceType)) |
+if (!browser.webRequest.ResourceType || |
+ !("OBJECT_SUBREQUEST" in browser.webRequest.ResourceType)) |
{ |
RegExpFilter.typeMap.OBJECT_SUBREQUEST = RegExpFilter.typeMap.OBJECT; |
} |
// Map of content types reported by the browser to the respecitve content types |
// used by Adblock Plus. Other content types are simply mapped to OTHER. |
let resourceTypes = new Map(function*() |
{ |
@@ -52,21 +52,21 @@ |
// Treat <img srcset> and <picture> the same as other images. |
yield ["imageset", "IMAGE"]; |
}()); |
exports.filterTypes = new Set(function*() |
{ |
// Microsoft Edge does not have webRequest.ResourceType or the devtools panel. |
// Since filterTypes is only used by devtools, we can just bail out here. |
- if (!(chrome.webRequest.ResourceType)) |
+ if (!(browser.webRequest.ResourceType)) |
return; |
- for (let type in chrome.webRequest.ResourceType) |
- yield resourceTypes.get(chrome.webRequest.ResourceType[type]) || "OTHER"; |
+ for (let type in browser.webRequest.ResourceType) |
+ yield resourceTypes.get(browser.webRequest.ResourceType[type]) || "OTHER"; |
// WEBSOCKET and WEBRTC get addressed through workarounds, even if the |
// webRequest API is lacking support to block these kind of requests. |
yield "WEBSOCKET"; |
yield "WEBRTC"; |
// POPUP and ELEMHIDE filters aren't blocked on the request level but by other |
// means. They don't have a corresponding value in webRequest.ResourceType. |
@@ -207,18 +207,18 @@ |
port.on("request.blockedByWrapper", (msg, sender) => |
{ |
// Chrome 58 onwards directly supports WebSocket blocking, so we can ignore |
// messages from the wrapper here (see https://crbug.com/129353). Hopefully |
// WebRTC will be supported soon too (see https://crbug.com/707683). |
// Edge supports neither webRequest.ResourceType nor WebSocket blocking yet: |
// https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10297376/ |
- if (chrome.webRequest.ResourceType && |
- (msg.requestType.toUpperCase() in chrome.webRequest.ResourceType)) |
+ if (browser.webRequest.ResourceType && |
+ (msg.requestType.toUpperCase() in browser.webRequest.ResourceType)) |
{ |
return false; |
} |
return ext.webRequest.onBeforeRequest._dispatch( |
new URL(msg.url), |
msg.requestType, |
sender.page, |