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

Commit

Permalink
Port Chromium changes to Edge
Browse files Browse the repository at this point in the history
  • Loading branch information
nicole-ashley committed Sep 6, 2016
1 parent 006c723 commit 70266ee
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 38 deletions.
25 changes: 10 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ uBlock Origin
* [Blocking](#blocking)
* [Quick tests](#quick-tests)
* [Installation](#installation)
* [Edge](#edge)
* [Chromium](#chromium)
* [Firefox](#firefox--firefox-for-android)
* [Microsoft Edge](#microsoft-edge)
Expand Down Expand Up @@ -116,19 +115,6 @@ Being lean and efficient doesn't mean blocking less<br>

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

#### Edge

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.

1. Download the latest release from [the Releases page](https://github.com/nikrolls/uBlock-Edge/releases)
2. Extract the zip file somewhere safe (it will need to remain there as long as you use the extension)
3. Browse to `about:flags` in Edge and turn on the option `Enable extension developer features`
4. Restart your browser
5. Go to Extensions in the browser menu and click `Load extension`
6. Select the `uBlock0.edge` folder you extracted earlier

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.

#### Chromium

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/).
Expand All @@ -154,7 +140,16 @@ Users of Debian 9 or later or Ubuntu 16.04 or later may simply

#### Microsoft Edge

Early development version by [@nikrolls](https://github.com/nikrolls): <https://github.com/nikrolls/uBlock-Edge#edge>.
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.

1. Download the latest release from [the Releases page](https://github.com/nikrolls/uBlock-Edge/releases)
2. Extract the zip file somewhere safe (it will need to remain there as long as you use the extension)
3. Browse to `about:flags` in Edge and turn on the option `Enable extension developer features`
4. Restart your browser
5. Go to Extensions in the browser menu and click `Load extension`
6. Select the `uBlock0.edge` folder you extracted earlier

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.

#### Note for all browsers

Expand Down
2 changes: 1 addition & 1 deletion platform/edge/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,

"name": "uBlock Origin",
"version": "1.7.7",
"version": "1.9.5.100",

"default_locale": "en",
"description": "__MSG_extShortDesc__",
Expand Down
56 changes: 34 additions & 22 deletions platform/edge/vapi-background.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ var browser = self.browser;
var manifest = browser.runtime.getManifest();

vAPI.chrome = true;
vAPI.cantWebsocket = true;

var noopFunc = function(){};

Expand Down Expand Up @@ -195,6 +196,12 @@ vAPI.storage = (function() {
vAPI.browserSettings = {
webRTCSupported: undefined,

// https://github.com/gorhill/uBlock/issues/875
// Must not leave `lastError` unchecked.
noopCallback: function() {
void chrome.runtime.lastError;
},

// https://github.com/gorhill/uBlock/issues/533
// We must first check wether this Chromium-based browser was compiled
// with WebRTC support. To do this, we use an iframe, this way the
Expand Down Expand Up @@ -241,30 +248,35 @@ vAPI.browserSettings = {
return;
}

// Older version of Chromium do not support this setting.
if ( typeof browser.privacy.network.webRTCMultipleRoutesEnabled !== 'object' ) {
return;
}

try {
browser.privacy.network.webRTCMultipleRoutesEnabled.set({
value: !!setting,
scope: 'regular'
}, function() {
void browser.runtime.lastError;
});
} catch(ex) {
console.error(ex);
var cp = chrome.privacy, cpi = cp.IPHandlingPolicy, cpn = cp.network;

// Older version of Chromium do not support this setting, and is
// marked as "deprecated" since Chromium 48.
if ( typeof cpn.webRTCMultipleRoutesEnabled === 'object' ) {
try {
cpn.webRTCMultipleRoutesEnabled.set({
value: !!setting,
scope: 'regular'
}, this.noopCallback);
} catch(ex) {
console.error(ex);
}
}

// This setting became available in Chromium 48.
if ( typeof cpn.webRTCIPHandlingPolicy === 'object' ) {
try {
cpn.webRTCIPHandlingPolicy.set({
value: !!setting ? cpi.DEFAULT : cpi.DEFAULT_PUBLIC_INTERFACE_ONLY,
scope: 'regular'
}, this.noopCallback);
} catch(ex) {
console.error(ex);
}
}
},

set: function(details) {
// https://github.com/gorhill/uBlock/issues/875
// Must not leave `lastError` unchecked.
var callback = function() {
void browser.runtime.lastError;
};

for ( var setting in details ) {
if ( details.hasOwnProperty(setting) === false ) {
continue;
Expand All @@ -275,7 +287,7 @@ vAPI.browserSettings = {
browser.privacy.network.networkPredictionEnabled.set({
value: !!details[setting],
scope: 'regular'
}, callback);
}, this.noopCallback);
} catch(ex) {
console.error(ex);
}
Expand All @@ -286,7 +298,7 @@ vAPI.browserSettings = {
browser.privacy.websites.hyperlinkAuditingEnabled.set({
value: !!details[setting],
scope: 'regular'
}, callback);
}, this.noopCallback);
} catch(ex) {
console.error(ex);
}
Expand Down
17 changes: 17 additions & 0 deletions platform/edge/vapi-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,23 @@ if ( vAPI.sessionId ) {

/******************************************************************************/

var referenceCounter = 0;

vAPI.lock = function() {
referenceCounter += 1;
};

vAPI.unlock = function() {
referenceCounter -= 1;
if ( referenceCounter === 0 ) {
// Eventually there will be code here to flush the javascript code
// from this file out of memory when it ends up unused.

}
};

/******************************************************************************/

vAPI.executionCost = {
start: function(){},
stop: function(){}
Expand Down

0 comments on commit 70266ee

Please sign in to comment.