LEFT | RIGHT |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 14 matching lines...) Expand all Loading... |
25 const {FilterNotifier} = require("filterNotifier"); | 25 const {FilterNotifier} = require("filterNotifier"); |
26 const {Prefs} = require("prefs"); | 26 const {Prefs} = require("prefs"); |
27 const {checkWhitelisted, getKey} = require("whitelisting"); | 27 const {checkWhitelisted, getKey} = require("whitelisting"); |
28 const {stringifyURL, extractHostFromFrame, isThirdParty} = require("url"); | 28 const {stringifyURL, extractHostFromFrame, isThirdParty} = require("url"); |
29 const {port} = require("messaging"); | 29 const {port} = require("messaging"); |
30 const devtools = require("devtools"); | 30 const devtools = require("devtools"); |
31 | 31 |
32 // Chrome can't distinguish between OBJECT_SUBREQUEST and OBJECT requests. | 32 // Chrome can't distinguish between OBJECT_SUBREQUEST and OBJECT requests. |
33 if (!chrome.webRequest.ResourceType || | 33 if (!chrome.webRequest.ResourceType || |
34 !("OBJECT_SUBREQUEST" in chrome.webRequest.ResourceType)) | 34 !("OBJECT_SUBREQUEST" in chrome.webRequest.ResourceType)) |
| 35 { |
35 RegExpFilter.typeMap.OBJECT_SUBREQUEST = RegExpFilter.typeMap.OBJECT; | 36 RegExpFilter.typeMap.OBJECT_SUBREQUEST = RegExpFilter.typeMap.OBJECT; |
| 37 } |
36 | 38 |
37 // Map of content types reported by the browser to the respecitve content types | 39 // Map of content types reported by the browser to the respecitve content types |
38 // used by Adblock Plus. Other content types are simply mapped to OTHER. | 40 // used by Adblock Plus. Other content types are simply mapped to OTHER. |
39 let resourceTypes = new Map(function*() | 41 let resourceTypes = new Map(function*() |
40 { | 42 { |
41 for (let type in RegExpFilter.typeMap) | 43 for (let type in RegExpFilter.typeMap) |
42 yield [type.toLowerCase(), type]; | 44 yield [type.toLowerCase(), type]; |
43 | 45 |
44 yield ["sub_frame", "SUBDOCUMENT"]; | 46 yield ["sub_frame", "SUBDOCUMENT"]; |
45 | 47 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 | 186 |
185 port.on("request.blockedByWrapper", (msg, sender) => | 187 port.on("request.blockedByWrapper", (msg, sender) => |
186 { | 188 { |
187 // Chrome 58 onwards directly supports WebSocket blocking, so we can ignore | 189 // Chrome 58 onwards directly supports WebSocket blocking, so we can ignore |
188 // messages from the wrapper here (see https://crbug.com/129353). Hopefully | 190 // messages from the wrapper here (see https://crbug.com/129353). Hopefully |
189 // WebRTC will be supported soon too (see https://crbug.com/707683). | 191 // WebRTC will be supported soon too (see https://crbug.com/707683). |
190 // Edge supports neither webRequest.ResourceType nor WebSocket blocking yet: | 192 // Edge supports neither webRequest.ResourceType nor WebSocket blocking yet: |
191 // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/102973
76/ | 193 // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/102973
76/ |
192 if (chrome.webRequest.ResourceType && | 194 if (chrome.webRequest.ResourceType && |
193 (msg.requestType.toUpperCase() in chrome.webRequest.ResourceType)) | 195 (msg.requestType.toUpperCase() in chrome.webRequest.ResourceType)) |
| 196 { |
194 return false; | 197 return false; |
| 198 } |
195 | 199 |
196 return ext.webRequest.onBeforeRequest._dispatch( | 200 return ext.webRequest.onBeforeRequest._dispatch( |
197 new URL(msg.url), | 201 new URL(msg.url), |
198 msg.requestType, | 202 msg.requestType, |
199 sender.page, | 203 sender.page, |
200 sender.frame | 204 sender.frame |
201 ).includes(false); | 205 ).includes(false); |
202 }); | 206 }); |
LEFT | RIGHT |