| Index: ext/background.js |
| =================================================================== |
| --- a/ext/background.js |
| +++ b/ext/background.js |
| @@ -558,16 +558,24 @@ |
| } |
| } |
| }); |
| }); |
| }); |
| chrome.webRequest.onBeforeRequest.addListener(details => |
| { |
| + // Filter out requests from non web protocols since Chrome version |
| + // 58 added support for webSocket connections to the webRequests API |
|
Jon Sonesen
2017/04/20 19:19:58
this comment should likely be improved. perhaps we
Sebastian Noack
2017/04/20 19:34:15
"Filter out requests from non web protocols. Ideal
Jon Sonesen
2017/04/20 19:53:06
Acknowledged. Thank you, I think that is good.
|
| + let blockURLs = new RegExp("https?|wss?"); |
| + let url = new URL(details.url); |
|
Sebastian Noack
2017/04/20 19:34:15
We are now creating two URL objects, one to valida
Jon Sonesen
2017/04/20 19:53:06
Ah, sorry about that.
|
| + if (!blockURLs.exec(url.protocol)) |
|
Sebastian Noack
2017/04/20 19:34:15
Since the regular expression doesn't make the code
Sebastian Noack
2017/04/20 19:36:22
I accidentally inverted the logic, should be of co
Jon Sonesen
2017/04/20 19:53:06
Yeah, happy to use this instead.
|
| + { |
|
Sebastian Noack
2017/04/20 19:34:15
We generally omit the braces if there is only one
Jon Sonesen
2017/04/20 19:53:06
Done.
|
| + return {cancel: false}; |
|
Sebastian Noack
2017/04/20 19:34:15
For consistency with the other bailout condition b
Jon Sonesen
2017/04/20 19:53:06
Done.
|
| + } |
| // The high-level code isn't interested in requests that aren't |
| // related to a tab or requests loading a top-level document, |
| // those should never be blocked. |
| if (details.tabId == -1 || details.type == "main_frame") |
| return; |
| // We are looking for the frame that contains the element which |
| // has triggered this request. For most requests (e.g. images) we |
| @@ -588,17 +596,17 @@ |
| type.toUpperCase(), |
| new Page({id: details.tabId}), |
| frame |
| ); |
| if (results.indexOf(false) != -1) |
| return {cancel: true}; |
| } |
| - }, {urls: ["https://*/*", "http://*/*", "ws://*/*", "wss://*/*"]}, ["blocking"]); |
| + }, {urls: ["<all_urls>"]}, ["blocking"]); |
| /* Message passing */ |
| chrome.runtime.onMessage.addListener((message, rawSender, sendResponse) => |
| { |
| let sender = {}; |