Microsoft has acquired GitHub. Decentraleyes has left GitHub. Welcome to its new home!

To participate, please register, or sign in with an existing GitLab.com, Bitbucket, or GitHub account.

Past contributions on GitHub? Be sure to reclaim your Comments, Issues, and Pull Requests.

...
 
Commits (13)
Decentraleyes
=============
A [web browser extension](https://decentraleyes.org) that emulates Content Delivery Networks locally by intercepting requests, finding the required resource and injecting it into the environment. This all happens instantaneously, automatically, and no prior configuration is required. Feel free to use this [testing utility](https://decentraleyes.org/test) to see if it's properly installed, enabled, and correctly configured.
A [web browser extension](https://decentraleyes.org) that emulates Content Delivery Networks to improve your online privacy. It intercepts traffic, finds supported resources locally, and injects them into the environment. All of this happens automatically, so no prior configuration is required. Feel free to use the following [testing utility](https://decentraleyes.org/test) to find out if you are properly protected.
> **Note:** Decentraleyes is no silver bullet, but it does prevent a lot of websites from making you send these kinds of requests. Ultimately, you can make Decentraleyes block requests for any missing CDN resources, too.
## Roadmap
Now that there's a solid, Mozilla approved, foundation, it's time to move forward. Mobility, extensibility (through support for community-powered resource packages), and usability, will be the main points of attention during this phase.
#### Essential Next Steps
* Start work on a resource bundle standard, to allow users to create and import custom resources. With support for these bundles in place, Decentraleyes will still work out of the box, but can be extended if needed.
* To keep this add-on from turning into bloatware, it's important to find out which versions of which libraries are most commonly used on websites, so that less popular resources can be removed from the default bundle.
#### Planned Features
* Advanced policy management for users who block requests for missing resources.
* Smarter resource version interpretation for handling dynamic notations.
* A minimalistic and non-essential graphical user interface.
* Support for custom, importable, library repositories.
> **Note:** These long-term goals are subjective to change, and can be discussed. That is, as long as the suggestions do not conflict with the ultimate goal of realizing a free and open standard for exchanging web resource bundles.
## Submitting Translations
Do you master a non-supported language? Please help out by translating this add-on on [Crowdin](https://crowdin.com/project/decentraleyes).
## Contributing Code
Suggestions in the form of **Issues** and contributions in the form of **Pull Requests** are highly welcome. You can also use the contact details and PGP key on the add-on [download page](https://addons.mozilla.org/firefox/addon/decentraleyes) to get in touch.
Suggestions in the form of **Issues**, and contributions in the form of **Pull Requests**, are highly welcome. You can also use the public contact details and PGP key on the extension's [contact page](https://decentraleyes.org/contact) to get in touch.
#### Prerequisites
* Jetpack Manager [jpm](https://developer.mozilla.org/Add-ons/SDK/Tools/jpm#Installation) (a Node-based replacement for cfx).
* Firefox version 38 or later. *If you need to work with earlier versions of Firefox, you'll need to use the old cfx tool. See instructions for [getting started with cfx](https://developer.mozilla.org/Add-ons/SDK/Tutorials/Getting_started).
* [Jetpack Manager](https://developer.mozilla.org/Add-ons/SDK/Tools/jpm#Installation) ```v1.3.1``` *(or higher)*.
* Mozilla Firefox 38 *(or higher)*.
> **Note:** If you want to contribute to the Firefox Quantum extension, please check out the ```master``` branch. If you are looking for the Chromium-compatible codebase, please see the ```experimental``` branch.
#### Build Instructions (Unix)
#### Building the Code (*nix)
git clone https://github.com/Synzvato/decentraleyes
git clone https://github.com/Synzvato/decentraleyes --branch legacy
cd decentraleyes
jpm xpi
> **Important:** All commits since 26 October 2016 are signed with GPG. It's likely best to ignore unsigned commits, unless you really know what you're doing. Please send an email if you have any questions or security concerns.
## Submitting Translations
Do you master a non-supported language? Please help out by translating this add-on on [Crowdin](https://crowdin.com/project/decentraleyes).
## License
[MPL-2.0](https://www.mozilla.org/MPL/2.0).
......@@ -21,6 +21,8 @@ var { Class } = require('sdk/core/heritage');
var { Unknown } = require('sdk/platform/xpcom');
var { Cc, Ci, Cr } = require('chrome');
var main = require('./main');
/**
* Gets and sets add-on specific preferences.
* @var {object} simplePreferences
......@@ -83,8 +85,10 @@ var Interceptor = new Class({
return;
}
// Remove referer header from request.
// Remove sensitive headers from the request.
httpChannel.setRequestHeader('Referer', null, false);
httpChannel.setRequestHeader('Origin', null, false);
httpChannel.setRequestHeader('Cookie', null, false);
// Convert the original request URI to a local target.
target = requestAnalyzer.getLocalTarget(httpChannel.URI.host, httpChannel.URI.path);
......@@ -116,6 +120,7 @@ var Interceptor = new Class({
//noinspection JSUnresolvedVariable
preferences.amountInjected++;
main.broadcastInjection();
},
/**
......
......@@ -106,7 +106,17 @@ var LoadWatcher = new Class({
shouldLoad: function (contentType, contentLocation, requestOrigin, node) {
if (contentType == SCRIPT_CONTENT_TYPE && mappings[contentLocation.host]) {
let contentHost;
try {
contentHost = contentLocation.host;
} catch (exception) {
// Accept the resource load request.
return REQUEST_ACCEPTATION;
}
if (contentType == SCRIPT_CONTENT_TYPE && mappings[contentHost]) {
if (node instanceof SCRIPT_ELEMENT) {
......
......@@ -17,15 +17,23 @@
* Imports
*/
var Interceptor = require('./interceptor');
var LoadWatcher = require('./load-watcher');
var preferences = require('sdk/simple-prefs');
var webextension = null;
var preferences = require('sdk/simple-prefs').prefs;
var self = require('sdk/self');
var tabs = require("sdk/tabs");
var Interceptor = require('./interceptor');
var LoadWatcher = require('./load-watcher');
/**
* Main
* Variables
*/
var webextensionPort = null;
/**
* Initializations
*/
var interceptor = new Interceptor();
......@@ -36,6 +44,10 @@ var featurelessVersions = {
'1.3.7': true
};
/**
* Main
*/
// Executed as soon as the add-on is loaded.
exports.main = function (options) {
......@@ -43,15 +55,75 @@ exports.main = function (options) {
interceptor.register();
loadWatcher.register();
if (preferences.showReleaseNotes) {
// Display the release notes if desired.
if (preferences.prefs.showReleaseNotes) {
if (options.loadReason === 'install' || (options.loadReason === 'upgrade' && !featurelessVersions[self.version])) {
if (preferences['sdk.baseURI']) {
tabs.open(preferences['sdk.baseURI'] + 'static/release-notes.html');
if (preferences.prefs['sdk.baseURI']) {
tabs.open(preferences.prefs['sdk.baseURI'] + 'static/release-notes.html');
}
}
}
try {
webextension = require('sdk/webextension');
} catch (exception) {
return;
}
// Initialize the embedded WebExtension.
webextension.startup().then(({ browser }) => {
browser.runtime.onConnect.addListener(port => {
if (port.name === 'webextension') {
webextensionPort = port;
preferences.on('', function (preferenceName) {
let content = null;
if (preferenceName === 'amountInjected') {
return;
}
if (preferenceName === 'domainWhitelist') {
let domainWhitelist = preferences.prefs['domainWhitelist'];
content = {
'whitelistedDomains': _parseDomainWhitelist(domainWhitelist)
};
} else {
content = {
[preferenceName]: preferences.prefs[preferenceName]
};
}
port.postMessage({
'subject': 'update-preferences',
'content': content
});
});
let domainWhitelist = preferences.prefs['domainWhitelist'];
port.postMessage({
'subject': 'migrate-preferences',
'content': {
'amountInjected': preferences.prefs['amountInjected'],
'blockMissing': preferences.prefs['blockMissing'],
'whitelistedDomains': _parseDomainWhitelist(domainWhitelist),
'showReleaseNotes': preferences.prefs['showReleaseNotes']
}
});
}
});
});
};
// Executed as soon as the add-on is unloaded.
......@@ -60,3 +132,40 @@ exports.onUnload = function () {
// Clean up add-on state.
interceptor.unregister();
};
// Sends injection updates to the WebExtension.
exports.broadcastInjection = function () {
if (webextensionPort !== null) {
webextensionPort.postMessage({
'subject': 'register-injection'
});
}
};
/**
* Private Methods
*/
function _parseDomainWhitelist(value) {
let whitelistedDomains = {};
value.split(';').forEach(function (domain) {
whitelistedDomains[_normalizeDomain(domain)] = true;
});
return whitelistedDomains;
}
function _normalizeDomain(domain) {
domain = domain.toLowerCase().trim();
if (domain.startsWith('www.')) {
domain = domain.slice(4);
}
return domain;
}
......@@ -342,6 +342,14 @@ var mappings = {
}
};
// Geekzu Public Service [Mirror]
mappings['sdn.geekzu.org'] = {
'/ajax/ajax/libs/': mappings['ajax.googleapis.com']['/ajax/libs/']
};
// USTC Linux User Group [Mirror]
mappings['ajax.proxy.ustclug.org'] = mappings['ajax.googleapis.com'];
/**
* Exports
*/
......
......@@ -78,8 +78,11 @@ exports.isValidCandidate = function (httpChannel) {
// If the request initiator could be determined and is whitelisted.
if (initiatorDomain && whitelistedDomains[_normalizeDomain(initiatorDomain)]) {
// Remove referer header from request.
// Remove sensitive headers from the request.
httpChannel.setRequestHeader('Referer', null, false);
httpChannel.setRequestHeader('Origin', null, false);
httpChannel.setRequestHeader('Cookie', null, false);
return false;
}
......
......@@ -3,11 +3,12 @@
"author": "Thomas Rientjes",
"license": "MPL-2.0",
"title": "Decentraleyes",
"version": "1.3.8",
"version": "1.3.10",
"main": "lib/main.js",
"homepage": "https://addons.mozilla.org/firefox/addon/decentraleyes",
"name": "decentraleyes",
"id": "jid1-BoFifL9Vbdl2zQ@jetpack",
"hasEmbeddedWebExtension": true,
"permissions": {
"multiprocess": true
},
......
This diff is collapsed.
/**
* Embedded WebExtension - Background Script
* Belongs to Decentraleyes.
*
* @author Thomas Rientjes
* @since 2017-08-18
* @license MPL 2.0
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
'use strict';
/**
* Variables
*/
var webextensionPort = {};
var amountInjected = null;
var pendingCount = 0;
/**
* Initializations
*/
webextensionPort = browser.runtime.connect({name: 'webextension'});
/**
* Event Handlers
*/
webextensionPort.onMessage.addListener((message) => {
if (message.subject === 'migrate-preferences') {
browser.storage.local.get(function (items) {
// Covers storage API failures.
if (items === null) {
return;
}
for (let preference of Object.keys(message.content)) {
// Makes sure no existing preferences are overwritten.
if (!items.hasOwnProperty(preference)) {
browser.storage.local.set({
[preference]: message.content[preference]
});
}
}
});
}
if (message.subject === 'register-injection') {
if (amountInjected !== null && !isNaN(amountInjected)) {
++amountInjected;
browser.storage.local.set({amountInjected});
}
++pendingCount;
if (pendingCount > 1) {
return;
}
chrome.storage.local.get({
// The stored amount, or zero.
amountInjected: 0
}, function (items) {
// Accounts for the fact that the storage API is asynchronous.
amountInjected = (items && items.amountInjected || 0) + pendingCount;
browser.storage.local.set({amountInjected});
});
}
if (message.subject === 'update-preferences') {
chrome.storage.local.set(message.content);
}
});
{
"manifest_version": 2,
"name": "Decentraleyes Module",
"version": "1.3.10",
"author": "Thomas Rientjes",
"background": {
"scripts": [
"background.js"
]
},
"permissions": [
"storage"
]
}