Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • Synzvato/decentraleyes
  • gkrishnaks/decentraleyes
  • ExE-Boss/decentraleyes
  • whtsky/decentraleyes
  • grtgarrett/decentraleyes
  • An_dz/decentraleyes
  • Alaska/decentraleyes
  • finn/decentraleyes
  • klippy/decentraleyes
9 results
Show changes
Commits on Source (31)
Showing with 613 additions and 267 deletions
locale
data
preferences
webextension
{
"env": {
"es6": true
},
"globals": {
"exports": true,
"module": true,
"require": true,
"Services": true
},
"extends": [
"eslint:recommended",
"plugin:no-unsanitized/DOM"
],
"overrides": {
"files": [
"test/*"
],
"rules": {
"brace-style": "off",
"function-paren-newline": "off",
"max-len": "off"
}
},
"plugins": [
"no-unsanitized"
],
"rules": {
"array-bracket-newline": "error",
"array-bracket-spacing": "error",
"arrow-body-style": "error",
"arrow-parens": "error",
"arrow-spacing": "error",
"block-spacing": "error",
"brace-style": "error",
"camelcase": "error",
"comma-spacing": "error",
"comma-style": "error",
"computed-property-spacing": "error",
"consistent-this": "error",
"curly": "error",
"eol-last": "error",
"eqeqeq": "error",
"func-call-spacing": "error",
"function-paren-newline": "error",
"generator-star-spacing": "error",
"indent": [
"error",
4
],
"key-spacing": "error",
"keyword-spacing": "error",
"linebreak-style": [
"error",
"unix"
],
"new-parens": "error",
"no-array-constructor": "error",
"no-bitwise": "error",
"no-confusing-arrow": "error",
"no-continue": "error",
"no-duplicate-imports": "error",
"no-eval": "error",
"no-extend-native": "error",
"no-implicit-coercion": "error",
"no-implied-eval": "error",
"no-invalid-this": "error",
"no-iterator": "error",
"no-label-var": "error",
"no-labels": "error",
"no-lone-blocks": "error",
"no-loop-func": "error",
"no-multi-spaces": "error",
"no-multi-str": "error",
"no-multiple-empty-lines": [
"error", {
"max": 1,
"maxEOF": 1,
"maxBOF": 0
}
],
"max-len": [
"error", {
"code": 120
}
],
"no-negated-condition": "error",
"no-new": "error",
"no-new-func": "error",
"no-new-object": "error",
"no-new-wrappers": "error",
"no-octal-escape": "error",
"no-proto": "error",
"no-return-assign": "error",
"no-return-await": "error",
"no-script-url": "error",
"no-self-compare": "error",
"no-sequences": "error",
"no-shadow-restricted-names": "error",
"no-tabs": "error",
"no-ternary": "error",
"no-throw-literal": "error",
"no-trailing-spaces": "error",
"no-undef-init": "error",
"no-unmodified-loop-condition": "error",
"no-unused-expressions": "error",
"no-useless-call": "error",
"no-useless-concat": "error",
"no-useless-constructor": "error",
"no-useless-rename": "error",
"no-useless-return": "error",
"no-void": "error",
"no-warning-comments": "warn",
"no-whitespace-before-property": "error",
"no-with": "error",
"object-curly-spacing": "error",
"object-shorthand": [
"error",
"consistent-as-needed"
],
"operator-assignment": "error",
"operator-linebreak": "error",
"prefer-numeric-literals": "error",
"prefer-promise-reject-errors": "error",
"quote-props": "error",
"prefer-rest-params": "error",
"prefer-spread": "error",
"prefer-template": "error",
"quotes": [
"error",
"single"
],
"rest-spread-spacing": "error",
"require-await": "error",
"semi": "error",
"semi-spacing": "error",
"semi-style": "error",
"space-before-blocks": "error",
"space-before-function-paren": "error",
"space-in-parens": "error",
"space-infix-ops": "error",
"space-unary-ops": "error",
"strict": [
"error",
"global"
],
"switch-colon-spacing": "error",
"symbol-description": "error",
"template-curly-spacing": "error",
"template-tag-spacing": "error",
"unicode-bom": "error",
"vars-on-top": "error",
"wrap-regex": "error",
"yield-star-spacing": "error",
"yoda": "error"
}
}
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://git.synz.io/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).
locale decentraleyes ar locale/ar/
locale decentraleyes bg locale/bg/
locale decentraleyes cs locale/cs/
locale decentraleyes da locale/da/
locale decentraleyes de locale/de/
locale decentraleyes en-GB locale/en-GB/
locale decentraleyes en-US locale/en-US/
locale decentraleyes eo locale/eo/
locale decentraleyes es locale/es/
locale decentraleyes et locale/et/
locale decentraleyes fi locale/fi/
locale decentraleyes fr locale/fr/
locale decentraleyes he locale/he/
locale decentraleyes id locale/id/
locale decentraleyes is locale/is/
locale decentraleyes it locale/it/
locale decentraleyes ja locale/ja/
locale decentraleyes ko locale/ko/
locale decentraleyes nl locale/nl/
locale decentraleyes pl locale/pl/
locale decentraleyes pt-BR locale/pt-BR/
locale decentraleyes pt-PT locale/pt-PT/
locale decentraleyes ro locale/ro/
locale decentraleyes ru locale/ru/
locale decentraleyes sv-SE locale/sv-SE/
locale decentraleyes sr locale/sr/
locale decentraleyes sv locale/sv/
locale decentraleyes tr locale/tr/
locale decentraleyes zh-CN locale/zh-CN/
locale decentraleyes zh-TW locale/zh-TW/
......@@ -17,7 +17,7 @@
* Imports
*/
var { Cc, Ci } = require('chrome');
var {Cc, Ci} = require('chrome');
var self = require('sdk/self');
//noinspection JSUnresolvedFunction
......@@ -34,7 +34,7 @@ var files = require('./files');
* Constants
*/
const DELIVERY_NOTICE = '/**\n * Local delivery by Decentraleyes (' + self.version + ').\n */\n\n';
const DELIVERY_NOTICE = `/**\n * Local delivery by Decentraleyes (${self.version}).\n */\n\n`;
/**
* Variables
......@@ -46,7 +46,7 @@ var resourceData = self.data;
* Public Methods
*/
function getRedirectionURI(targetPath, characterSet, type) {
function getRedirectionURI (targetPath, characterSet, type) {
var data, dataURI, redirectionURI;
......@@ -67,9 +67,7 @@ exports.getRedirectionURI = getRedirectionURI;
* Private Methods
*/
function _loadResource(targetPath) {
var resource;
function _loadResource (targetPath) {
// Find the result inside a static path index.
if (!files[targetPath]) {
......@@ -77,24 +75,24 @@ function _loadResource(targetPath) {
}
// Attempt to load resource contents.
return resource = resourceData.load(targetPath);
return resourceData.load(targetPath);
}
function _buildDataURI(type, characterSet, data) {
function _buildDataURI (type, characterSet, data) {
var addNotice, dataURI;
//noinspection JSUnresolvedVariable
addNotice = require('sdk/simple-prefs').prefs.addNotice;
dataURI = 'data:' + type + ';charset=' + characterSet + ',';
dataURI = `data:${type};charset=${characterSet},`;
// Remove the syntax invalidation character.
data = data.substring(1);
if (!addNotice) {
dataURI = dataURI + encodeURIComponent(data);
if (addNotice) {
dataURI += encodeURIComponent(DELIVERY_NOTICE + data);
} else {
dataURI = dataURI + encodeURIComponent(DELIVERY_NOTICE + data);
dataURI += encodeURIComponent(data);
}
return dataURI;
......
......@@ -17,9 +17,11 @@
* Imports
*/
var { Class } = require('sdk/core/heritage');
var { Unknown } = require('sdk/platform/xpcom');
var { Cc, Ci, Cr } = require('chrome');
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.
......@@ -53,15 +55,15 @@ var storage = simpleStorage.storage;
var Interceptor = new Class({
extends: Unknown,
interfaces: ['nsIObserver'],
topic: 'http-on-modify-request',
'extends': Unknown,
'interfaces': ['nsIObserver'],
'topic': 'http-on-modify-request',
register: function () {
'register': function () {
observerService.addObserver(this, this.topic, false);
},
unregister: function () {
'unregister': function () {
observerService.removeObserver(this, this.topic);
},
......@@ -69,9 +71,9 @@ var Interceptor = new Class({
* Called whenever an HTTP request is made.
* @param httpChannel
*/
observe: function (httpChannel) {
'observe': function (httpChannel) {
var validCandidate, target, characterSet, redirectionURI;
var validCandidate, target, characterSet, redirectionURI, initiatorDomain;
// Enable runtime discovery.
httpChannel.QueryInterface(Ci.nsIHttpChannel);
......@@ -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);
......@@ -103,11 +107,12 @@ var Interceptor = new Class({
}
// Fix for reported edge-case issues with specific websites.
var initiatorDomain =
httpChannel.loadInfo && httpChannel.loadInfo.loadingDocument && httpChannel.loadInfo.loadingDocument.domain ||
initiatorDomain =
httpChannel.loadInfo && httpChannel.loadInfo.loadingDocument &&
httpChannel.loadInfo.loadingDocument.domain ||
httpChannel.referrer && httpChannel.referrer.host;
if (storage.taintedDomains[initiatorDomain] || /yandex\./.test(initiatorDomain)) {
if (storage.taintedDomains[initiatorDomain] || (/yandex\./).test(initiatorDomain)) {
return this.handleMissingCandidate(httpChannel);
}
......@@ -116,13 +121,14 @@ var Interceptor = new Class({
//noinspection JSUnresolvedVariable
preferences.amountInjected++;
main.broadcastInjection();
},
/**
* Called when a valid candidate cannot be injected.
* @param httpChannel
*/
handleMissingCandidate: function (httpChannel) {
'handleMissingCandidate': function (httpChannel) {
//noinspection JSUnresolvedVariable
if (preferences.blockMissing) {
......
......@@ -17,9 +17,9 @@
* Imports
*/
var { Class } = require('sdk/core/heritage');
var { Unknown, Factory } = require('sdk/platform/xpcom');
var { Cc, Ci, Cu } = require('chrome');
var {Class} = require('sdk/core/heritage');
var {Unknown, Factory} = require('sdk/platform/xpcom');
var {Cc, Ci, Cu} = require('chrome');
var xpcom = require('sdk/platform/xpcom');
......@@ -52,13 +52,14 @@ const REQUEST_ACCEPTATION = Ci.nsIContentPolicy.ACCEPT;
* Variables
*/
var storage = simpleStorage.storage;
var LoadWatcher, storage, undetectableTaintedDomains, factory, unload;
storage = simpleStorage.storage;
/**
* Tainted domains that are not automatically detectable.
* @var {object} undetectableTaintedDomains
*/
var undetectableTaintedDomains = {
undetectableTaintedDomains = {
'identi.ca': true,
'minigames.mail.ru': true,
......@@ -73,7 +74,7 @@ var undetectableTaintedDomains = {
Object.extend = function (destination, source) {
for (var property in source) {
for (let property in source) {
if (source.hasOwnProperty(property)) {
destination[property] = source[property];
......@@ -90,23 +91,35 @@ storage.taintedDomains = Object.extend(storage.taintedDomains, undetectableTaint
* Load Watcher Class
*/
var LoadWatcher = new Class({
LoadWatcher = new Class({
extends: Unknown,
interfaces: ['nsIContentPolicy'],
get wrappedJSObject() {
return this
'extends': Unknown,
'interfaces': ['nsIContentPolicy'],
// eslint-disable-next-line quote-props
get wrappedJSObject () {
return this;
},
register: function () {
'register': function () {
categoryManager.deleteCategoryEntry('content-policy', CONTRACT_ID, false);
categoryManager.addCategoryEntry('content-policy', CONTRACT_ID, CONTRACT_ID, false, true);
},
shouldLoad: function (contentType, contentLocation, requestOrigin, node) {
'shouldLoad': function (contentType, contentLocation, requestOrigin, node) {
let contentHost;
try {
contentHost = contentLocation.host;
} catch (exception) {
// Accept the resource load request.
return REQUEST_ACCEPTATION;
}
if (contentType == SCRIPT_CONTENT_TYPE && mappings[contentLocation.host]) {
if (contentType === SCRIPT_CONTENT_TYPE && mappings[contentHost]) {
if (node instanceof SCRIPT_ELEMENT) {
......@@ -127,22 +140,22 @@ var LoadWatcher = new Class({
* Load Watcher Factory
*/
var factory = Factory({
factory = Factory({
contract: CONTRACT_ID,
Component: LoadWatcher,
unregister: false
'contract': CONTRACT_ID,
'Component': LoadWatcher,
'unregister': false
});
/**
* Unregister
*/
var unload = require('sdk/system/unload');
unload = require('sdk/system/unload');
unload.when(function () {
function trueUnregister() {
function trueUnregister () {
categoryManager.deleteCategoryEntry('content-policy', CONTRACT_ID, false);
......
......@@ -17,15 +17,23 @@
* Imports
*/
var preferences = require('sdk/simple-prefs');
var webextension = null;
var self = require('sdk/self');
var tabs = require('sdk/tabs');
var Interceptor = require('./interceptor');
var LoadWatcher = require('./load-watcher');
var preferences = require('sdk/simple-prefs').prefs;
var self = require('sdk/self');
var tabs = require("sdk/tabs");
/**
* Variables
*/
var webextensionPort = null;
/**
* Main
* 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,77 @@ 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])) {
let loadReason = options.loadReason;
if (preferences['sdk.baseURI']) {
tabs.open(preferences['sdk.baseURI'] + 'static/release-notes.html');
if (loadReason === 'install' || (loadReason === 'upgrade' && !featurelessVersions[self.version])) {
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 +134,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;
}
......@@ -41,105 +41,48 @@ var mappings = {
'swfobject/{version}/swfobject.': resources.swfobject,
'webfont/{version}/webfont.': resources.webfont,
// Common Shorthand Notations [Deprecated]
// Basic Shorthand Notations [Deprecated]
'dojo/1/dojo/dojo.': {
path: 'resources/dojo/1.6.1/dojo/dojo.js.dec',
type: 'application/javascript'
'path': 'resources/dojo/1.6.1/dojo/dojo.js.dec',
'type': 'application/javascript'
},
'jquery/1/jquery.': {
path: 'resources/jquery/1.11.1/jquery.min.js.dec',
type: 'application/javascript'
},
'jquery/1.2/jquery.min.js': {
path: 'resources/jquery/1.2.6/jquery.min.js.dec',
type: 'application/javascript'
},
'jquery/1.2/jquery.js': {
path: 'resources/jquery/1.2.6/jquery.min.js.dec',
type: 'application/javascript'
},
'jquery/1.3/jquery.min.js': {
path: 'resources/jquery/1.3.2/jquery.min.js.dec',
type: 'application/javascript'
},
'jquery/1.3/jquery.js': {
path: 'resources/jquery/1.3.2/jquery.min.js.dec',
type: 'application/javascript'
},
'jquery/1.4/jquery.min.js': {
path: 'resources/jquery/1.4.4/jquery.min.js.dec',
type: 'application/javascript'
},
'jquery/1.4/jquery.js': {
path: 'resources/jquery/1.4.4/jquery.min.js.dec',
type: 'application/javascript'
},
'jquery/1.5/jquery.min.js': {
path: 'resources/jquery/1.5.2/jquery.min.js.dec',
type: 'application/javascript'
},
'jquery/1.5/jquery.js': {
path: 'resources/jquery/1.5.2/jquery.min.js.dec',
type: 'application/javascript'
},
'jquery/1.6/jquery.min.js': {
path: 'resources/jquery/1.6.4/jquery.min.js.dec',
type: 'application/javascript'
},
'jquery/1.6/jquery.js': {
path: 'resources/jquery/1.6.4/jquery.min.js.dec',
type: 'application/javascript'
},
'jquery/1.7/jquery.min.js': {
path: 'resources/jquery/1.7.2/jquery.min.js.dec',
type: 'application/javascript'
},
'jquery/1.7/jquery.js': {
path: 'resources/jquery/1.7.2/jquery.min.js.dec',
type: 'application/javascript'
},
'jquery/1.8/jquery.min.js': {
path: 'resources/jquery/1.8.3/jquery.min.js.dec',
type: 'application/javascript'
},
'jquery/1.8/jquery.js': {
path: 'resources/jquery/1.8.3/jquery.min.js.dec',
type: 'application/javascript'
'path': 'resources/jquery/1.11.1/jquery.min.js.dec',
'type': 'application/javascript'
},
'jqueryui/1/jquery-ui.js': {
path: 'resources/jqueryui/1.10.4/jquery-ui.min.js.dec',
type: 'application/javascript'
'path': 'resources/jqueryui/1.10.4/jquery-ui.min.js.dec',
'type': 'application/javascript'
},
'jqueryui/1/jquery-ui.min.js': {
path: 'resources/jqueryui/1.10.4/jquery-ui.min.js.dec',
type: 'application/javascript'
'path': 'resources/jqueryui/1.10.4/jquery-ui.min.js.dec',
'type': 'application/javascript'
},
'mootools/1/mootools-yui-compressed.': {
path: 'resources/mootools/1.1.2/mootools-yui-compressed.js.dec',
type: 'application/javascript'
'path': 'resources/mootools/1.1.2/mootools-yui-compressed.js.dec',
'type': 'application/javascript'
},
'prototype/1/prototype.': {
path: 'resources/prototype/1.7.1.0/prototype.js.dec',
type: 'application/javascript'
'path': 'resources/prototype/1.7.1.0/prototype.js.dec',
'type': 'application/javascript'
},
'scriptaculous/1/scriptaculous.': {
path: 'resources/scriptaculous/1.9.0/scriptaculous.js.dec',
type: 'application/javascript'
'path': 'resources/scriptaculous/1.9.0/scriptaculous.js.dec',
'type': 'application/javascript'
},
'swfobject/2/swfobject.': {
path: 'resources/swfobject/2.2/swfobject.js.dec',
type: 'application/javascript'
'path': 'resources/swfobject/2.2/swfobject.js.dec',
'type': 'application/javascript'
},
'webfont/1/webfont.': {
path: 'resources/webfont/1.5.18/webfont.js.dec',
type: 'application/javascript'
'path': 'resources/webfont/1.5.18/webfont.js.dec',
'type': 'application/javascript'
}
}
},
// Microsoft Ajax CDN
'ajax.aspnetcdn.com': {
'/ajax/': {
'jQuery/jquery-{version}.': resources.jQuery,
'jquery/jquery-{version}.': resources.jQuery,
'modernizr/modernizr-{version}.': resources.modernizr
}
......@@ -147,7 +90,6 @@ var mappings = {
// Microsoft Ajax CDN [Deprecated]
'ajax.microsoft.com': {
'/ajax/': {
'jQuery/jquery-{version}.': resources.jQuery,
'jquery/jquery-{version}.': resources.jQuery,
'modernizr/modernizr-{version}.': resources.modernizr
}
......@@ -180,54 +122,14 @@ var mappings = {
'ui/{version}/jquery-ui.js': resources.jQueryUI,
'ui/{version}/jquery-ui.min.js': resources.jQueryUI,
// Common Shorthand Notations [Deprecated]
// Basic Shorthand Notations [Deprecated]
'jquery-latest.': {
path: 'resources/jquery/1.11.1/jquery.min.js.dec',
type: 'application/javascript'
'path': 'resources/jquery/1.11.1/jquery.min.js.dec',
'type': 'application/javascript'
},
'jquery.': {
path: 'resources/jquery/1.11.1/jquery.min.js.dec',
type: 'application/javascript'
},
'jquery-1.3.min.js': {
path: 'resources/jquery/1.3.0/jquery.min.js.dec',
type: 'application/javascript'
},
'jquery-1.3.js': {
path: 'resources/jquery/1.3.0/jquery.min.js.dec',
type: 'application/javascript'
},
'jquery-1.4.min.js': {
path: 'resources/jquery/1.4.0/jquery.min.js.dec',
type: 'application/javascript'
},
'jquery-1.4.js': {
path: 'resources/jquery/1.4.0/jquery.min.js.dec',
type: 'application/javascript'
},
'jquery-1.5.min.js': {
path: 'resources/jquery/1.5.0/jquery.min.js.dec',
type: 'application/javascript'
},
'jquery-1.5.js': {
path: 'resources/jquery/1.5.0/jquery.min.js.dec',
type: 'application/javascript'
},
'jquery-1.6.min.js': {
path: 'resources/jquery/1.6.0/jquery.min.js.dec',
type: 'application/javascript'
},
'jquery-1.6.js': {
path: 'resources/jquery/1.6.0/jquery.min.js.dec',
type: 'application/javascript'
},
'jquery-1.7.min.js': {
path: 'resources/jquery/1.7.0/jquery.min.js.dec',
type: 'application/javascript'
},
'jquery-1.7.js': {
path: 'resources/jquery/1.7.0/jquery.min.js.dec',
type: 'application/javascript'
'path': 'resources/jquery/1.11.1/jquery.min.js.dec',
'type': 'application/javascript'
}
}
},
......@@ -342,6 +244,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
*/
......
......@@ -23,6 +23,12 @@
*/
var mappings = require('./mappings');
/**
* Resource version shorthands.
* @var {object} shorthands
*/
var shorthands = require('./shorthands');
/**
* Gets and sets add-on specific preferences.
* @var {object} simplePreferences
......@@ -65,21 +71,32 @@ simplePreferences.on('domainWhitelist', _applyWhitelistPreference);
exports.isValidCandidate = function (httpChannel) {
var initiatorDomain;
// See if the request uses a supported URI scheme.
if (!httpChannel.URI.schemeIs('http') &&
!httpChannel.URI.schemeIs('https')) {
return false;
}
// See if the request is targeted at a Content Delivery Network.
if (mappings[httpChannel.URI.host] === undefined) {
return false;
}
// Attempt to determine the domain of the request initiator.
var initiatorDomain =
initiatorDomain =
httpChannel.loadInfo && httpChannel.loadInfo.loadingDocument && httpChannel.loadInfo.loadingDocument.domain ||
httpChannel.referrer && httpChannel.referrer.host;
// 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;
}
......@@ -107,14 +124,14 @@ exports.getLocalTarget = function (channelHost, channelPath) {
}
// Return either the local target's path or false.
return _findLocalTarget(resourceMappings, basePath, channelPath);
return _findLocalTarget(resourceMappings, basePath, channelHost, channelPath);
};
/**
* Private Methods
*/
function _matchBasePath(hostMappings, channelPath) {
function _matchBasePath (hostMappings, channelPath) {
for (let basePath of Object.keys(hostMappings)) {
......@@ -126,7 +143,7 @@ function _matchBasePath(hostMappings, channelPath) {
return false;
}
function _findLocalTarget(resourceMappings, basePath, channelPath) {
function _findLocalTarget (resourceMappings, basePath, channelHost, channelPath) {
var resourcePath, versionNumber, resourcePattern;
......@@ -140,8 +157,8 @@ function _findLocalTarget(resourceMappings, basePath, channelPath) {
// Prepare and return a local target.
return {
path: resourceMappings[resourcePath].path,
type: resourceMappings[resourcePath].type
'path': resourceMappings[resourcePath].path,
'type': resourceMappings[resourcePath].type
};
}
......@@ -150,10 +167,26 @@ function _findLocalTarget(resourceMappings, basePath, channelPath) {
if (resourcePattern.startsWith(resourceMold)) {
let targetPath, targetType, hostShorthands;
targetPath = resourceMappings[resourceMold].path;
targetPath = targetPath.replace(VERSION_PLACEHOLDER, versionNumber);
targetType = resourceMappings[resourceMold].type;
hostShorthands = shorthands[channelHost];
if (hostShorthands && hostShorthands[targetPath]) {
let shorthand = hostShorthands[targetPath];
targetPath = shorthand.path;
targetType = shorthand.type;
}
// Prepare and return a local target.
return {
path: resourceMappings[resourceMold].path.replace(VERSION_PLACEHOLDER, versionNumber),
type: resourceMappings[resourceMold].type
'path': targetPath,
'type': targetType
};
}
}
......@@ -161,7 +194,7 @@ function _findLocalTarget(resourceMappings, basePath, channelPath) {
return false;
}
function _normalizeDomain(domain) {
function _normalizeDomain (domain) {
domain = domain.toLowerCase().trim();
......@@ -172,7 +205,7 @@ function _normalizeDomain(domain) {
return domain;
}
function _applyWhitelistPreference() {
function _applyWhitelistPreference () {
whitelistedDomains = {};
......
......@@ -20,74 +20,74 @@
var resources = {
// AngularJS
angular: {
path: 'resources/angularjs/{version}/angular.min.js.dec',
type: 'application/javascript'
'angular': {
'path': 'resources/angularjs/{version}/angular.min.js.dec',
'type': 'application/javascript'
},
// Backbone.js
backbone: {
path: 'resources/backbone.js/{version}/backbone-min.js.dec',
type: 'application/javascript'
'backbone': {
'path': 'resources/backbone.js/{version}/backbone-min.js.dec',
'type': 'application/javascript'
},
// Dojo
dojo: {
path: 'resources/dojo/{version}/dojo/dojo.js.dec',
type: 'application/javascript'
'dojo': {
'path': 'resources/dojo/{version}/dojo/dojo.js.dec',
'type': 'application/javascript'
},
// Ember.js
ember: {
path: 'resources/ember.js/{version}/ember.min.js.dec',
type: 'application/javascript'
'ember': {
'path': 'resources/ember.js/{version}/ember.min.js.dec',
'type': 'application/javascript'
},
// Ext Core
extCore: {
path: 'resources/ext-core/{version}/ext-core.js.dec',
type: 'application/javascript'
'extCore': {
'path': 'resources/ext-core/{version}/ext-core.js.dec',
'type': 'application/javascript'
},
// jQuery
jQuery: {
path: 'resources/jquery/{version}/jquery.min.js.dec',
type: 'application/javascript'
'jQuery': {
'path': 'resources/jquery/{version}/jquery.min.js.dec',
'type': 'application/javascript'
},
// jQuery UI
jQueryUI: {
path: 'resources/jqueryui/{version}/jquery-ui.min.js.dec',
type: 'application/javascript'
'jQueryUI': {
'path': 'resources/jqueryui/{version}/jquery-ui.min.js.dec',
'type': 'application/javascript'
},
// Modernizr
modernizr: {
path: 'resources/modernizr/{version}/modernizr.min.js.dec',
type: 'application/javascript'
'modernizr': {
'path': 'resources/modernizr/{version}/modernizr.min.js.dec',
'type': 'application/javascript'
},
// MooTools
mootools: {
path: 'resources/mootools/{version}/mootools-yui-compressed.js.dec',
type: 'application/javascript'
'mootools': {
'path': 'resources/mootools/{version}/mootools-yui-compressed.js.dec',
'type': 'application/javascript'
},
// Prototype
prototypeJS: {
path: 'resources/prototype/{version}/prototype.js.dec',
type: 'application/javascript'
'prototypeJS': {
'path': 'resources/prototype/{version}/prototype.js.dec',
'type': 'application/javascript'
},
// Scriptaculous
scriptaculous: {
path: 'resources/scriptaculous/{version}/scriptaculous.js.dec',
type: 'application/javascript'
'scriptaculous': {
'path': 'resources/scriptaculous/{version}/scriptaculous.js.dec',
'type': 'application/javascript'
},
// SWFObject
swfobject: {
path: 'resources/swfobject/{version}/swfobject.js.dec',
type: 'application/javascript'
'swfobject': {
'path': 'resources/swfobject/{version}/swfobject.js.dec',
'type': 'application/javascript'
},
// Underscore.js
underscore: {
path: 'resources/underscore.js/{version}/underscore-min.js.dec',
type: 'application/javascript'
'underscore': {
'path': 'resources/underscore.js/{version}/underscore-min.js.dec',
'type': 'application/javascript'
},
// Web Font Loader
webfont: {
path: 'resources/webfont/{version}/webfont.js.dec',
type: 'application/javascript'
'webfont': {
'path': 'resources/webfont/{version}/webfont.js.dec',
'type': 'application/javascript'
}
};
......
/**
* Shorthands
* Belongs to Decentraleyes.
*
* @author Thomas Rientjes
* @since 2018-06-02
* @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';
/**
* Shorthands
*/
var shorthands = {
// Google Hosted Libraries [Deprecated]
'ajax.googleapis.com': {
'resources/jquery/1.8/jquery.min.js.dec': {
'path': 'resources/jquery/1.8.3/jquery.min.js.dec',
'version': '1.8.3'
},
'resources/jquery/1.7/jquery.min.js.dec': {
'path': 'resources/jquery/1.7.2/jquery.min.js.dec',
'version': '1.7.2'
},
'resources/jquery/1.6/jquery.min.js.dec': {
'path': 'resources/jquery/1.6.4/jquery.min.js.dec',
'version': '1.6.4'
},
'resources/jquery/1.5/jquery.min.js.dec': {
'path': 'resources/jquery/1.5.2/jquery.min.js.dec',
'version': '1.5.2'
},
'resources/jquery/1.4/jquery.min.js.dec': {
'path': 'resources/jquery/1.4.4/jquery.min.js.dec',
'version': '1.4.4'
},
'resources/jquery/1.3/jquery.min.js.dec': {
'path': 'resources/jquery/1.3.2/jquery.min.js.dec',
'version': '1.3.2'
},
'resources/jquery/1.2/jquery.min.js.dec': {
'path': 'resources/jquery/1.2.6/jquery.min.js.dec',
'version': '1.2.6'
}
},
// jQuery CDN [Deprecated]
'code.jquery.com': {
'resources/jquery/1.7/jquery.min.js.dec': {
'path': 'resources/jquery/1.7.0/jquery.min.js.dec',
'version': '1.7.0'
},
'resources/jquery/1.6/jquery.min.js.dec': {
'path': 'resources/jquery/1.6.0/jquery.min.js.dec',
'version': '1.6.0'
},
'resources/jquery/1.5/jquery.min.js.dec': {
'path': 'resources/jquery/1.5.0/jquery.min.js.dec',
'version': '1.5.0'
},
'resources/jquery/1.4/jquery.min.js.dec': {
'path': 'resources/jquery/1.4.0/jquery.min.js.dec',
'version': '1.4.0'
},
'resources/jquery/1.3/jquery.min.js.dec': {
'path': 'resources/jquery/1.3.0/jquery.min.js.dec',
'version': '1.3.0'
}
}
};
// Geekzu Public Service [Mirror]
shorthands['sdn.geekzu.org'] = shorthands['ajax.googleapis.com'];
// USTC Linux User Group [Mirror]
shorthands['ajax.proxy.ustclug.org'] = shorthands['ajax.googleapis.com'];
/**
* Exports
*/
module.exports = shorthands;
<!ENTITY options.addNotice.title "إضافة تعليقات إلى الملفات التي تم جلبها محليا">
<!ENTITY options.addNotice.description "إلحاق إشعار إلى الوثائق التي تم إستيرادها للإشارة إلى مصدرها محليا.">
<!ENTITY options.blockMissing.title "حظر طلبات الموارد المفقودة">
<!ENTITY options.blockMissing.description "إلغاء طلب الموارد إذا كانت متوفرة محليا.">
<!ENTITY options.domainWhitelist.title "لا تتفحص النطاقات">
<!ENTITY options.domainWhitelist.description "حدد النطاقات اللتي سوف يتم تجاهلها. إفصل المداخل المتعددة بـفاصلة منقوطة (;).">
<!ENTITY options.amountInjected.title "عداد محلي للموارد المحقونة">
<!ENTITY options.amountInjected.description "إجمالي موارد الـ CDN اللتي تم حقنها محليا منذ التثبيت.">
......@@ -2,7 +2,7 @@
<!ENTITY options.addNotice.description "Автоматично вмъкване на известие към извлечените документи, за да се сигнализира местна доставка.">
<!ENTITY options.blockMissing.title "Блокиране на заявки за липсващи ресурси">
<!ENTITY options.blockMissing.description "Отмяна на прехванатата заявка, ако изисквания ресурс не е наличен на местно ниво.">
<!ENTITY options.domainWhitelist.title "Изключване на домейните от инспекции">
<!ENTITY options.domainWhitelist.title "Изключване на домейни от проверки">
<!ENTITY options.domainWhitelist.description "Въведете домейни, които да се добавят в белия списък. Отделете стойностите с точка и запетая.">
<!ENTITY options.amountInjected.title "Брояч за местно вмъкнати ресурси">
<!ENTITY options.amountInjected.description "Количество на местни вмъквания на ресурси от началото на инсталацията.">
<!ENTITY options.addNotice.title "Přidat komentáře k lokálně uloženým souborům">
<!ENTITY options.addNotice.description "Automaticky přidat poznámku k získaným dokumentům a označit je jako lokálně stažené.">
<!ENTITY options.blockMissing.title "Blokovat požadavky na chybějící zdroje">
<!ENTITY options.blockMissing.description "Zrušit požadavky na sledované zdroje, pokud nejsou lokálně dostupné.">
<!ENTITY options.domainWhitelist.title "Nekontrolovat pro domény">
<!ENTITY options.domainWhitelist.description "Zadejte domény pro jejich vynechání z kontroly. Jednotlivé domény oddělujte pomocí středníků (;).">
<!ENTITY options.amountInjected.title "Počítadlo vložených lokálních zdrojů">
<!ENTITY options.amountInjected.description "Počet lokální uložených zdrojů vložených od instalace.">
<!ENTITY options.addNotice.title "Tilføj kommentarer til lokalt hentede filer">
<!ENTITY options.addNotice.description "Tilføj automatiskt en notits til filer, så det fremgår at de er leveret lokalt.">
<!ENTITY options.blockMissing.title "Bloker anmodninger om manglende ressourcer">
<!ENTITY options.blockMissing.description "Annullerer en anmodning hvis den forespurgte ressource ikke findes lokalt.">
<!ENTITY options.blockMissing.title "Bloker forespørgsler efter manglende ressourcer">
<!ENTITY options.blockMissing.description "Annullerer en forespørgsel hvis den forespurgte ressource ikke findes lokalt.">
<!ENTITY options.domainWhitelist.title "Udeluk disse domæner fra inspektion">
<!ENTITY options.domainWhitelist.description "Tilføj domæner der ikke skal opfanges. Separer flere med semikolon (;).">
<!ENTITY options.domainWhitelist.description "Tilføj domæner der ikke skal inspiceres. Separer flere med semikolon (;).">
<!ENTITY options.amountInjected.title "Optælling af lokalt leverede ressourcer">
<!ENTITY options.amountInjected.description "Antal injektioner af lokale ressourcer siden installation.">
<!ENTITY options.addNotice.title "Lisa kommentaare kohalikult toodud failidele">
<!ENTITY options.addNotice.description "Automaatselt lisa teade saadud dokumentidele, et märgistada kohalik edastus.">
<!ENTITY options.blockMissing.title "Blokeeri puuduvate ressursside taotlused">
<!ENTITY options.blockMissing.description "Tühista kinnipüütud taotlus, kui vajaminev ressurss ei ole kohalikult saadaval.">
<!ENTITY options.domainWhitelist.title "Välista uuritavaid domeene">
<!ENTITY options.domainWhitelist.description "Sisesta domeenid, et lisada need valgesse nimekirja. Eralda mitu üksust semikoolonitega (;).">
<!ENTITY options.amountInjected.title "Kohalikult sisestatud ressursside loendur">
<!ENTITY options.amountInjected.description "Kohalike sisuedastusvõrkude ressursisisestuste arv alates installimisest.">
......@@ -3,6 +3,6 @@
<!ENTITY options.blockMissing.title "Estä pyynnöt puuttuviin resursseihin">
<!ENTITY options.blockMissing.description "Estää pyynnöt jos paikallista sisältöä ei ole saatavilla.">
<!ENTITY options.domainWhitelist.title "Poissulje verkkotunnukset">
<!ENTITY options.domainWhitelist.description "Lisää verkkotunnus jottei sitä korvata. Erota rivit puolipisteellä (;).">
<!ENTITY options.domainWhitelist.description "Seuraavat verkkotunnukset ohitetaan, eikä niitä korvata. Erota rivit puolipisteellä (;).">
<!ENTITY options.amountInjected.title "Korvatut pyynnöt">
<!ENTITY options.amountInjected.description "Korvatut sisältöpyynnöt lisäosan asennuksen jälkeen.">
......@@ -3,6 +3,6 @@
<!ENTITY options.blockMissing.title "Bloquer les ressources manquantes">
<!ENTITY options.blockMissing.description "Annuler une demande de ressource si elle est indisponible localement.">
<!ENTITY options.domainWhitelist.title "Ne pas inspecter certains domaines">
<!ENTITY options.domainWhitelist.description "Indiquez les domaines à exclure. Séparer les noms par un point-virgule (;).">
<!ENTITY options.amountInjected.title "Compteur des ressources injectées">
<!ENTITY options.amountInjected.description "Total des ressources des CDN injectées localement depuis l'installation.">
<!ENTITY options.domainWhitelist.description "Entrez des domaines à la liste blanche. Séparez les entrées multiples par des points-virgules (;).">
<!ENTITY options.amountInjected.title "Compteur de ressources injectées localement">
<!ENTITY options.amountInjected.description "Quantité d'injections de ressources CDN locales depuis l'installation.">
<!ENTITY options.addNotice.title "הוסף הערות לקבצים מקומיים">
<!ENTITY options.addNotice.description "צרף הודעה באופן אוטומטי למסמכים שאוחזרו, כדי לאשר שמירה מקומית.">
<!ENTITY options.blockMissing.title "חסום בקשות למשאבים חסרים">
<!ENTITY options.blockMissing.description "בטל בקשה מיורטת, אם המשאב הדרוש אינו זמין באופן מקומי.">
<!ENTITY options.domainWhitelist.title "אל תכלול דומיינים כחלק מהבדיקה">
<!ENTITY options.domainWhitelist.description "הזן דומיינים שברצונך להוסיף לרשימת התרים. הפרד ערכים מרובים באמצעות נקודה-פסיק (;).">
<!ENTITY options.amountInjected.title "מונה משאבים מקומיים שהוזרקו">
<!ENTITY options.amountInjected.description "כמות תוכן מקומי שהוזרק במקום רשתות אספקת תוכן מאז התקנת התוכנה.">