Skip to content
This repository was archived by the owner on Oct 11, 2020. It is now read-only.

Commit 70266ee

Browse files
committed
Port Chromium changes to Edge
1 parent 006c723 commit 70266ee

File tree

4 files changed

+62
-38
lines changed

4 files changed

+62
-38
lines changed

README.md

+10-15
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ uBlock Origin
4949
* [Blocking](#blocking)
5050
* [Quick tests](#quick-tests)
5151
* [Installation](#installation)
52-
* [Edge](#edge)
5352
* [Chromium](#chromium)
5453
* [Firefox](#firefox--firefox-for-android)
5554
* [Microsoft Edge](#microsoft-edge)
@@ -116,19 +115,6 @@ Being lean and efficient doesn't mean blocking less<br>
116115

117116
Feel free to read [about the extension's required permissions](https://github.com/gorhill/uBlock/wiki/About-the-required-permissions).
118117

119-
#### Edge
120-
121-
While in pre-release, you will need to side-load the extension. You need to have the Windows 10 Anniversary Update to use extensions in Edge.
122-
123-
1. Download the latest release from [the Releases page](https://github.com/nikrolls/uBlock-Edge/releases)
124-
2. Extract the zip file somewhere safe (it will need to remain there as long as you use the extension)
125-
3. Browse to `about:flags` in Edge and turn on the option `Enable extension developer features`
126-
4. Restart your browser
127-
5. Go to Extensions in the browser menu and click `Load extension`
128-
6. Select the `uBlock0.edge` folder you extracted earlier
129-
130-
Edge disables side-loaded extensions whenever you restart the browser. However after a few seconds you will get a prompt to re-enable them with a single clik.
131-
132118
#### Chromium
133119

134120
You can install the latest version [manually](https://github.com/gorhill/uBlock/tree/master/dist#install), from the [Chrome Store](https://chrome.google.com/webstore/detail/ublock-origin/cjpalhdlnbpafiamejdnhcphjbkeiagm), or from the [Opera store](https://addons.opera.com/en-gb/extensions/details/ublock/).
@@ -154,7 +140,16 @@ Users of Debian 9 or later or Ubuntu 16.04 or later may simply
154140

155141
#### Microsoft Edge
156142

157-
Early development version by [@nikrolls](https://github.com/nikrolls): <https://github.com/nikrolls/uBlock-Edge#edge>.
143+
While in pre-release, you will need to side-load the extension. You need to have the Windows 10 Anniversary Update to use extensions in Edge.
144+
145+
1. Download the latest release from [the Releases page](https://github.com/nikrolls/uBlock-Edge/releases)
146+
2. Extract the zip file somewhere safe (it will need to remain there as long as you use the extension)
147+
3. Browse to `about:flags` in Edge and turn on the option `Enable extension developer features`
148+
4. Restart your browser
149+
5. Go to Extensions in the browser menu and click `Load extension`
150+
6. Select the `uBlock0.edge` folder you extracted earlier
151+
152+
Edge disables side-loaded extensions whenever you restart the browser. However after a few seconds you will get a prompt to re-enable them with a single clik.
158153

159154
#### Note for all browsers
160155

platform/edge/manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifest_version": 2,
33

44
"name": "uBlock Origin",
5-
"version": "1.7.7",
5+
"version": "1.9.5.100",
66

77
"default_locale": "en",
88
"description": "__MSG_extShortDesc__",

platform/edge/vapi-background.js

+34-22
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ var browser = self.browser;
3535
var manifest = browser.runtime.getManifest();
3636

3737
vAPI.chrome = true;
38+
vAPI.cantWebsocket = true;
3839

3940
var noopFunc = function(){};
4041

@@ -195,6 +196,12 @@ vAPI.storage = (function() {
195196
vAPI.browserSettings = {
196197
webRTCSupported: undefined,
197198

199+
// https://github.com/gorhill/uBlock/issues/875
200+
// Must not leave `lastError` unchecked.
201+
noopCallback: function() {
202+
void chrome.runtime.lastError;
203+
},
204+
198205
// https://github.com/gorhill/uBlock/issues/533
199206
// We must first check wether this Chromium-based browser was compiled
200207
// with WebRTC support. To do this, we use an iframe, this way the
@@ -241,30 +248,35 @@ vAPI.browserSettings = {
241248
return;
242249
}
243250

244-
// Older version of Chromium do not support this setting.
245-
if ( typeof browser.privacy.network.webRTCMultipleRoutesEnabled !== 'object' ) {
246-
return;
247-
}
248-
249-
try {
250-
browser.privacy.network.webRTCMultipleRoutesEnabled.set({
251-
value: !!setting,
252-
scope: 'regular'
253-
}, function() {
254-
void browser.runtime.lastError;
255-
});
256-
} catch(ex) {
257-
console.error(ex);
251+
var cp = chrome.privacy, cpi = cp.IPHandlingPolicy, cpn = cp.network;
252+
253+
// Older version of Chromium do not support this setting, and is
254+
// marked as "deprecated" since Chromium 48.
255+
if ( typeof cpn.webRTCMultipleRoutesEnabled === 'object' ) {
256+
try {
257+
cpn.webRTCMultipleRoutesEnabled.set({
258+
value: !!setting,
259+
scope: 'regular'
260+
}, this.noopCallback);
261+
} catch(ex) {
262+
console.error(ex);
263+
}
264+
}
265+
266+
// This setting became available in Chromium 48.
267+
if ( typeof cpn.webRTCIPHandlingPolicy === 'object' ) {
268+
try {
269+
cpn.webRTCIPHandlingPolicy.set({
270+
value: !!setting ? cpi.DEFAULT : cpi.DEFAULT_PUBLIC_INTERFACE_ONLY,
271+
scope: 'regular'
272+
}, this.noopCallback);
273+
} catch(ex) {
274+
console.error(ex);
275+
}
258276
}
259277
},
260278

261279
set: function(details) {
262-
// https://github.com/gorhill/uBlock/issues/875
263-
// Must not leave `lastError` unchecked.
264-
var callback = function() {
265-
void browser.runtime.lastError;
266-
};
267-
268280
for ( var setting in details ) {
269281
if ( details.hasOwnProperty(setting) === false ) {
270282
continue;
@@ -275,7 +287,7 @@ vAPI.browserSettings = {
275287
browser.privacy.network.networkPredictionEnabled.set({
276288
value: !!details[setting],
277289
scope: 'regular'
278-
}, callback);
290+
}, this.noopCallback);
279291
} catch(ex) {
280292
console.error(ex);
281293
}
@@ -286,7 +298,7 @@ vAPI.browserSettings = {
286298
browser.privacy.websites.hyperlinkAuditingEnabled.set({
287299
value: !!details[setting],
288300
scope: 'regular'
289-
}, callback);
301+
}, this.noopCallback);
290302
} catch(ex) {
291303
console.error(ex);
292304
}

platform/edge/vapi-client.js

+17
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,23 @@ if ( vAPI.sessionId ) {
6767

6868
/******************************************************************************/
6969

70+
var referenceCounter = 0;
71+
72+
vAPI.lock = function() {
73+
referenceCounter += 1;
74+
};
75+
76+
vAPI.unlock = function() {
77+
referenceCounter -= 1;
78+
if ( referenceCounter === 0 ) {
79+
// Eventually there will be code here to flush the javascript code
80+
// from this file out of memory when it ends up unused.
81+
82+
}
83+
};
84+
85+
/******************************************************************************/
86+
7087
vAPI.executionCost = {
7188
start: function(){},
7289
stop: function(){}

0 commit comments

Comments
 (0)