Skip to content
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.

Commit

Permalink
Added support for websocket
Browse files Browse the repository at this point in the history
  • Loading branch information
uBlockAdmin committed Sep 26, 2018
1 parent 46a249e commit 4e75e4c
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 8 deletions.
3 changes: 1 addition & 2 deletions platform/chromium/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@
"webNavigation",
"webRequest",
"webRequestBlocking",
"http://*/*",
"https://*/*"
"<all_urls>"
],
"short_name": "uBlock"
}
17 changes: 17 additions & 0 deletions platform/chromium/vapi-background.js
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,23 @@ vAPI.net.registerListeners = function() {
normalizeRequestDetails(details);
return onBeforeRequestClient(details);
};

var urls, types;
urls = this.onBeforeRequest.urls || ['<all_urls>'];
types = this.onBeforeRequest.types || [];
if (
(chrome.webRequest.ResourceType.WEBSOCKET == 'websocket') &&
(urls.indexOf('<all_urls>') === -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) {
Expand Down
3 changes: 1 addition & 2 deletions platform/webext/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@
"webNavigation",
"webRequest",
"webRequestBlocking",
"http://*/*",
"https://*/*"
"<all_urls>"
],
"short_name": "uBlock"
}
4 changes: 2 additions & 2 deletions src/js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ return {

// read-only
systemSettings: {
compiledMagic: 'eopszukpnrcq',
selfieMagic: 'menhiasrxfed'
compiledMagic: 'eopszukpnrcj',
selfieMagic: 'menhiasrxfee'
},
restoreBackupSettings: {
lastRestoreFile: '',
Expand Down
6 changes: 4 additions & 2 deletions src/js/static-net-filtering.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -1318,7 +1319,8 @@ FilterParser.prototype.toNormalizedType = {
'elemhide': 'cosmetic-filtering',
'inline-script': 'inline-script',
'popup': 'popup',
'csp' : 'csp'
'csp' : 'csp',
'websocket': 'websocket'
};

/******************************************************************************/
Expand Down

0 comments on commit 4e75e4c

Please sign in to comment.