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.

Verified Commit 24992e26 authored by Thomas Rientjes's avatar Thomas Rientjes
Browse files

Update and refactor existing codebase

parent ab43484f
module.exports = {
'artifactsDir': 'artifacts',
'ignoreFiles': ['crowdin.yaml'],
'build': {
'overwriteDest': true
}
};
artifacts
audit/node_modules
audit/report.txt
Decentraleyes (Experimental)
Decentraleyes (Chromium)
=============
A reimplementation of current features of Decentraleyes. This project will help bring Decentraleyes to WebExtensions (Firefox 57 and higher), as well as Chromium-based browsers, Opera, and possibly even Edge.
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. For more information, please read this [basic introduction](https://git.synz.io/Synzvato/decentraleyes/wikis/Simple-Introduction).
## Changelog
> **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.
Below is a list of all notable changes made to the reimplementation project to date. This includes, but is most certainly not limited to, records of changes such as bug fixes, and new, removed, and updated features.
## Contributing Code
### v1.3.7.5
Suggestions in the form of **Issues**, and contributions in the form of **Merge Requests**, are highly welcome. Code **Forks** can be requested from within issues, or via email. You can use the contact details and public PGP key on the extension's [contact page](https://decentraleyes.org/contact/) to get in touch.
* Fix Subresource Integrity (SRI) validation issues.
* Implement context stripping for allowed CDN requests.
* Implement request filters to improve performance.
#### Prerequisites
### v1.3.7.4
* Chromium / Chrome 58 *(or higher)*.
* Fix rare injection counter issue.
> **Note:** If you want to contribute to the Firefox Quantum extension, please check out the ```master``` branch. If you are looking for the Firefox legacy extension codebase, please see the ```legacy``` branch.
### v1.3.7.3
#### Running the Code
* Improve injection state management _(requires a new permission)_.
* Implement injection overview and icon badge.
Please read this [developer guide](https://developer.chrome.com/extensions/getstarted) for information on how to run the extension from source.
### v1.3.7.2
> **Important:** All tagged 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.
* Fix popup icon display issue.
## Submitting Translations
### v1.3.7.1
Do you master a non-supported language? Please help out by translating this add-on on [Crowdin](https://crowdin.com/project/decentraleyes).
* Improve compatibility with HTTPS Everywhere.
## License
### v1.3.7
* Initial release.
[MPL-2.0](https://www.mozilla.org/MPL/2.0).
......@@ -21,10 +21,14 @@ const Address = {
'ANY': '*://*/*',
'ANY_PATH': '/*',
'ANY_PROTOCOL': '*://',
'CHROME': 'chrome:',
'CHROME_EXTENSION': 'chrome-extension:',
'DECENTRALEYES': 'decentraleyes.org',
'EXAMPLE': 'example.org',
'HTTP': 'http:',
'HTTPS': 'https:',
'RESOURCE_PATH': '/resources',
'ROOT_PATH': '/',
'WWW_PREFIX': 'www.'
};
......@@ -63,6 +67,7 @@ const WebRequest = {
};
const WebRequestType = {
'MAIN_FRAME': 'main_frame',
'XHR': 'xmlhttprequest'
};
......
......@@ -2,7 +2,7 @@
* File Guard
* Belongs to Decentraleyes.
*
* @see https://github.com/Synzvato/decentraleyes/pull/258
* @see https://git.synz.io/Synzvato/decentraleyes/merge_requests/258
*
* @author Thomas Rientjes
* @since 2018-05-17
......@@ -32,14 +32,14 @@ fileGuard._startListening = function () {
chrome.webRequest.onBeforeRequest.addListener(
fileGuard._verifyRequest,
{'urls': [`${fileGuard.path}/*`]},
{'urls': [fileGuard.path + Address.ANY_PATH]},
[WebRequest.BLOCKING]
);
};
fileGuard._verifyRequest = function (requestDetails) {
let redirectUrl = chrome.runtime.getURL('/');
let redirectUrl = chrome.runtime.getURL(Address.ROOT_PATH);
if (!requestDetails.url.endsWith(fileGuard.secret)) {
return {redirectUrl};
......@@ -50,7 +50,7 @@ fileGuard._verifyRequest = function (requestDetails) {
* Initializations
*/
fileGuard.path = chrome.runtime.getURL('/resources');
fileGuard.path = chrome.runtime.getURL(Address.RESOURCE_PATH);
fileGuard.secret = '';
if (fileGuard.path.startsWith(Address.CHROME_EXTENSION)) {
......
......@@ -83,10 +83,7 @@ interceptor.handleRequest = function (requestDetails, tabIdentifier, tab) {
};
if (undetectableTaintedDomains[tabDomain] || (/yandex\./).test(tabDomain)) {
if (tabDomain !== 'yandex.ru') {
return interceptor._handleMissingCandidate(requestDetails.url);
}
return interceptor._handleMissingCandidate(requestDetails.url);
}
targetDetails = requestAnalyzer.getLocalTarget(requestDetails);
......@@ -157,7 +154,7 @@ interceptor._handleStorageChanged = function (changes) {
*/
interceptor.amountInjected = 0;
interceptor.xhrTestDomain = 'decentraleyes.org';
interceptor.xhrTestDomain = Address.DECENTRALEYES;
interceptor.blockMissing = false;
interceptor.relatedSettings = [];
......@@ -169,7 +166,7 @@ interceptor.relatedSettings.push(Setting.BLOCK_MISSING);
chrome.storage.local.get(interceptor.relatedSettings, function (items) {
interceptor.amountInjected = items.amountInjected || 0;
interceptor.xhrTestDomain = items.xhrTestDomain || 'decentraleyes.org';
interceptor.xhrTestDomain = items.xhrTestDomain || Address.DECENTRALEYES;
interceptor.blockMissing = items.blockMissing || false;
});
......
......@@ -26,7 +26,7 @@ var main = {};
main._initializeOptions = function () {
let optionDefaults = {
[Setting.XHR_TEST_DOMAIN]: 'decentraleyes.org',
[Setting.XHR_TEST_DOMAIN]: Address.DECENTRALEYES,
[Setting.SHOW_ICON_BADGE]: true,
[Setting.BLOCK_MISSING]: false,
[Setting.DISABLE_PREFETCH]: true,
......
......@@ -235,6 +235,28 @@ var mappings = {
'modernizr/modernizr-{version}.': resources.modernizr,
'mootoolscore/mootools.core-{version}.': resources.mootools
}
},
// BootCDN
'cdn.bootcss.com': {
'/': {
'angular.js/{version}/angular.': resources.angular,
'backbone.js/{version}/backbone.': resources.backbone,
'backbone.js/{version}/backbone-min.': resources.backbone,
'dojo/{version}/dojo.': resources.dojo,
'ember.js/{version}/ember.': resources.ember,
'ext-core/{version}/ext-core.': resources.extCore,
'jquery/{version}/jquery.': resources.jQuery,
'jqueryui/{version}/jquery-ui.js': resources.jQueryUI,
'jqueryui/{version}/jquery-ui.min.js': resources.jQueryUI,
'modernizr/{version}/modernizr.': resources.modernizr,
'mootools/{version}/mootools-yui-compressed.': resources.mootools,
'prototype/{version}/prototype.': resources.prototypeJS,
'scriptaculous/{version}/scriptaculous.': resources.scriptaculous,
'swfobject/{version}/swfobject.': resources.swfobject,
'underscore.js/{version}/underscore.': resources.underscore,
'underscore.js/{version}/underscore-min.': resources.underscore,
'webfont/{version}/webfontloader.': resources.webfont
}
}
};
......
......@@ -33,9 +33,14 @@ stateManager.registerInjection = function (tabIdentifier, injection) {
registeredTab.injections[injectionIdentifier] = injection;
injectionCount = Object.keys(registeredTab.injections).length || 0;
if (stateManager.showIconBadge === true) {
if (injectionCount > 0) {
if (injectionCount > 0) {
chrome.browserAction.setTitle({
'tabId': tabIdentifier,
'title': `Decentraleyes (${injectionCount})`
});
if (stateManager.showIconBadge === true) {
wrappers.setBadgeText({
'tabId': tabIdentifier,
......@@ -100,7 +105,6 @@ stateManager._createTab = function (tab) {
};
requestFilters = {
'tabId': tabIdentifier,
'urls': stateManager.validHosts
};
......@@ -119,23 +123,37 @@ stateManager._removeTab = function (tabIdentifier) {
stateManager._updateTab = function (details) {
let tabIdentifier, frameIdentifier;
let tabDomain, domainIsWhitelisted, frameIdentifier, tabIdentifier;
tabDomain = helpers.extractDomainFromUrl(details.url);
domainIsWhitelisted = stateManager._domainIsWhitelisted(tabDomain);
tabIdentifier = details.tabId;
frameIdentifier = details.frameId;
tabIdentifier = details.tabId;
if (tabIdentifier === -1 || frameIdentifier !== 0) {
if (frameIdentifier !== 0 || tabIdentifier === -1) {
return;
}
if (stateManager.showIconBadge === true) {
chrome.browserAction.setTitle({
'tabId': tabIdentifier,
'title': 'Decentraleyes (0)'
});
if (domainIsWhitelisted) {
wrappers.setBadgeText({
stateManager._setIconDisabled(tabIdentifier);
chrome.browserAction.setTitle({
'tabId': tabIdentifier,
'text': ''
'title': 'Decentraleyes (–)'
});
}
if (stateManager.showIconBadge === true) {
stateManager._clearBadgeText(tabIdentifier);
}
if (stateManager.tabs[tabIdentifier]) {
stateManager.tabs[tabIdentifier].injections = {};
}
......@@ -165,20 +183,58 @@ stateManager._handleStorageChanged = function (changes) {
}
};
stateManager._removeIconBadgeFromTab = function (tab) {
stateManager._clearBadgeText = function (tabIdentifier) {
wrappers.setBadgeText({
'tabId': tab.id,
'tabId': tabIdentifier,
'text': ''
});
};
stateManager._removeIconBadgeFromTab = function (tab) {
stateManager._clearBadgeText(tab.id);
};
stateManager._domainIsWhitelisted = function (domain) {
if (domain !== null) {
let whitelistRecord, isWhitelisted;
whitelistRecord = requestAnalyzer.whitelistedDomains[domain];
isWhitelisted = Boolean(whitelistRecord);
return isWhitelisted;
}
return false;
};
stateManager._setIconDisabled = function (tabIdentifier) {
wrappers.setIcon({
'path': stateManager.disabledIconPath,
'tabId': tabIdentifier
});
};
/**
* Initializations
*/
stateManager.requests = {};
stateManager.tabs = {};
stateManager.disabledIconPath = {
'16': chrome.runtime.getURL('icons/action/icon16-disabled.png'),
'18': chrome.runtime.getURL('icons/action/icon18-disabled.png'),
'19': chrome.runtime.getURL('icons/action/icon19-disabled.png'),
'32': chrome.runtime.getURL('icons/action/icon32-disabled.png'),
'36': chrome.runtime.getURL('icons/action/icon36-disabled.png'),
'38': chrome.runtime.getURL('icons/action/icon38-disabled.png'),
'64': chrome.runtime.getURL('icons/action/icon64-disabled.png')
};
stateManager.validHosts = [];
for (let mapping in mappings) {
......@@ -216,7 +272,7 @@ chrome.webRequest.onBeforeRequest.addListener(function (requestDetails) {
};
}
}, {'types': ['main_frame'], 'urls': [Address.ANY]});
}, {'types': [WebRequestType.MAIN_FRAME], 'urls': [Address.ANY]});
chrome.webNavigation.onCommitted.addListener(stateManager._updateTab, {
'url': [{'urlContains': ':'}]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment