From 4e75e4cfabf9634ed5d899bf6f735309f8b27074 Mon Sep 17 00:00:00 2001 From: uBlock <35694050+uBlockAdmin@users.noreply.github.com> Date: Wed, 26 Sep 2018 18:52:51 +0530 Subject: [PATCH] Added support for websocket --- platform/chromium/manifest.json | 3 +-- platform/chromium/vapi-background.js | 17 +++++++++++++++++ platform/webext/manifest.json | 3 +-- src/js/background.js | 4 ++-- src/js/static-net-filtering.js | 6 ++++-- 5 files changed, 25 insertions(+), 8 deletions(-) diff --git a/platform/chromium/manifest.json b/platform/chromium/manifest.json index 2476baca9..9a3be684d 100644 --- a/platform/chromium/manifest.json +++ b/platform/chromium/manifest.json @@ -57,8 +57,7 @@ "webNavigation", "webRequest", "webRequestBlocking", - "http://*/*", - "https://*/*" + "" ], "short_name": "uBlock" } diff --git a/platform/chromium/vapi-background.js b/platform/chromium/vapi-background.js index 9199a9090..6c4b806a8 100644 --- a/platform/chromium/vapi-background.js +++ b/platform/chromium/vapi-background.js @@ -710,6 +710,23 @@ vAPI.net.registerListeners = function() { normalizeRequestDetails(details); return onBeforeRequestClient(details); }; + + var urls, types; + urls = this.onBeforeRequest.urls || ['']; + types = this.onBeforeRequest.types || []; + if ( + (chrome.webRequest.ResourceType.WEBSOCKET == 'websocket') && + (urls.indexOf('') === -1) + ) { + types.push('websocket'); + if ( urls.indexOf('ws://*/*') === -1 ) { + urls.push('ws://*/*'); + } + if ( urls.indexOf('wss://*/*') === -1 ) { + urls.push('wss://*/*'); + } + } + chrome.webRequest.onBeforeRequest.addListener( onBeforeRequest, //function(details) { diff --git a/platform/webext/manifest.json b/platform/webext/manifest.json index bff2e0315..71ea4075c 100644 --- a/platform/webext/manifest.json +++ b/platform/webext/manifest.json @@ -63,8 +63,7 @@ "webNavigation", "webRequest", "webRequestBlocking", - "http://*/*", - "https://*/*" + "" ], "short_name": "uBlock" } diff --git a/src/js/background.js b/src/js/background.js index 6f694321c..d30a18213 100644 --- a/src/js/background.js +++ b/src/js/background.js @@ -91,8 +91,8 @@ return { // read-only systemSettings: { - compiledMagic: 'eopszukpnrcq', - selfieMagic: 'menhiasrxfed' + compiledMagic: 'eopszukpnrcj', + selfieMagic: 'menhiasrxfee' }, restoreBackupSettings: { lastRestoreFile: '', diff --git a/src/js/static-net-filtering.js b/src/js/static-net-filtering.js index 7c3e6c27e..85cd4c65b 100644 --- a/src/js/static-net-filtering.js +++ b/src/js/static-net-filtering.js @@ -62,7 +62,8 @@ var typeNameToTypeValue = { 'script': 4 << 4, 'xmlhttprequest': 5 << 4, 'sub_frame': 6 << 4, - 'other': 7 << 4, + 'websocket': 9 << 4, + 'other': 10 << 4, 'cosmetic-filtering': 13 << 4, 'inline-script': 14 << 4, 'popup': 15 << 4, @@ -1318,7 +1319,8 @@ FilterParser.prototype.toNormalizedType = { 'elemhide': 'cosmetic-filtering', 'inline-script': 'inline-script', 'popup': 'popup', - 'csp' : 'csp' + 'csp' : 'csp', + 'websocket': 'websocket' }; /******************************************************************************/