Index: lib/csp.js |
=================================================================== |
--- a/lib/csp.js |
+++ b/lib/csp.js |
@@ -10,30 +10,28 @@ |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* GNU General Public License for more details. |
* |
* You should have received a copy of the GNU General Public License |
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
*/ |
-"use strict"; |
+import {defaultMatcher} from "matcher"; |
+import {BlockingFilter, RegExpFilter} from "filterClasses"; |
+import {getDecodedHostname} from "url"; |
+import {checkWhitelisted} from "whitelisting"; |
// The webRequest API doesn't support WebSocket connection blocking in Microsoft |
// Edge and versions of Chrome before 58. Therefore for those we inject CSP |
// headers below as a workaround. See https://crbug.com/129353 and |
// https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10297376/ |
if (!browser.webRequest.ResourceType || |
!("WEBSOCKET" in browser.webRequest.ResourceType)) |
{ |
- const {defaultMatcher} = require("matcher"); |
- const {BlockingFilter, RegExpFilter} = require("filterClasses"); |
- const {getDecodedHostname} = require("url"); |
- const {checkWhitelisted} = require("whitelisting"); |
- |
browser.webRequest.onHeadersReceived.addListener(details => |
{ |
let hostname = getDecodedHostname(new URL(details.url)); |
let match = defaultMatcher.matchesAny("", RegExpFilter.typeMap.WEBSOCKET, |
hostname, false, null, true); |
if (match instanceof BlockingFilter && |
!checkWhitelisted(new ext.Page({id: details.tabId}), |
ext.getFrame(details.tabId, details.frameId))) |