Merge pull request 'develop' (#2) from develop into master

This commit is contained in:
nobody 2020-05-21 14:06:18 +02:00
commit 9e60976f32
7 changed files with 82 additions and 66 deletions

View File

@ -1,7 +1,6 @@
LocalCDN (forked from Decentraleyes)
=============
# LocalCDN
A web browser extension 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://localcdn.de/test/) to find out if you are properly protected. For more information, please read this [basic introduction from Decentraleyes](https://git.synz.io/Synzvato/decentraleyes/wikis/Simple-Introduction) or our [Wiki pages](https://codeberg.org/nobody/LocalCDN/wiki).
A web browser extension 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://localcdn.de/test/) to find out if you are properly protected. For more information, please read this [basic introduction from Decentraleyes](https://git.synz.io/Synzvato/decentraleyes/wikis/Simple-Introduction) or our [Wiki pages](https://gitlab.com/nobody42/localcdn/-/wikis/home).
## Differences between LocalCDN and Decentraleyes
@ -17,9 +16,10 @@ LocalCDN based on Decentraleyes. It includes more frameworks and more CDNs:
> **Note:** LocalCDN is no silver bullet, but it does prevent a lot of websites from making you send these kinds of requests. Ultimately, you can make LocalCDN block requests for any missing CDN resources, too.
## What is the different of LocalCDN in comparison to other CDN emulators?
<img src="/screenshots/replacement.png?raw=true" alt="The Replacement of Libraries">
<img src="https://localcdn.de/img/replacement.png" alt="The Replacement of Libraries">
**Advantages of LocalCDN:**
@ -31,49 +31,43 @@ LocalCDN based on Decentraleyes. It includes more frameworks and more CDNs:
:thumbsup: doesn't matter which version a website requested
## We need you!
![We Need You!](/pages/welcome/we-need-you.png?raw=true "We Need You!")
![We Need You!](https://localcdn.de/img/we-need-you.png "We Need You!")
The whole Internet is full of different frameworks and CDNs that negatively affect your privacy. If you find a website that embeds another unsupported version of a framework, please report that website.
### :warning: **Important** :warning:
In some cases, it isn't possible to use our framework because the website sets up a strong "Same Origin Policy" (SOP). Please read [Broken JavaScript or CSS on some websites](https://gitlab.com/nobody42/localcdn/-/wikis/faq/Broken-JavaScript-or-CSS-on-some-websites) before opening an issue.
In some cases, it isn't possible to use our framework because the website sets up a strong "Same Origin Policy" (SOP). Please read [Broken JavaScript or CSS on some websites](https://codeberg.org/nobody/LocalCDN/wiki/Broken-JavaScript-or-CSS-on-some-websites) before opening an issue.
On behalf of everyone: Thank you!
## Screenshots
### Light
<img src="/screenshots/screenshot01_light.png?raw=true" alt="Counter for locally injected resources (enabled)" width="200px">
<img src="/screenshots/screenshot02_light.png?raw=true" alt="Counter for locally injected resources (disabled)" width="200px">
<img src="/screenshots/screenshot03_light.png?raw=true" alt="Successfully intercepted requests" width="200px">
<img src="/screenshots/screenshot04_light.png?raw=true" alt="Successfully intercepted requests" width="200px">
[![Counter for locally injected resources (enabled)](https://localcdn.de/img/screenshots/screenshot01_light_preview.png)](https://localcdn.de/img/screenshots/screenshot01_light.png) [![Counter for locally injected resources (disabled)](https://localcdn.de/img/screenshots/screenshot02_light_preview.png)](https://localcdn.de/img/screenshots/screenshot02_light.png) [![Successfully intercepted requests](https://localcdn.de/img/screenshots/screenshot03_light_preview.png)](https://localcdn.de/img/screenshots/screenshot03_light.png) [![Successfully intercepted requests](https://localcdn.de/img/screenshots/screenshot04_light_preview.png)](https://localcdn.de/img/screenshots/screenshot04_light.png)
### Dark
<img src="/screenshots/screenshot01_dark.png?raw=true" alt="Counter for locally injected resources (enabled)" width="200px">
<img src="/screenshots/screenshot02_dark.png?raw=true" alt="Counter for locally injected resources (disabled)" width="200px">
<img src="/screenshots/screenshot03_dark.png?raw=true" alt="Successfully intercepted requests" width="200px">
<img src="/screenshots/screenshot04_dark.png?raw=true" alt="Successfully intercepted requests" width="200px">
[![Counter for locally injected resources (enabled)](https://localcdn.de/img/screenshots/screenshot01_dark_preview.png)](https://localcdn.de/img/screenshots/screenshot01_dark.png) [![Counter for locally injected resources (disabled)](https://localcdn.de/img/screenshots/screenshot02_dark_preview.png)](https://localcdn.de/img/screenshots/screenshot02_dark.png) [![Successfully intercepted requests](https://localcdn.de/img/screenshots/screenshot03_dark_preview.png)](https://localcdn.de/img/screenshots/screenshot03_dark.png) [![Successfully intercepted requests](https://localcdn.de/img/screenshots/screenshot04_dark_preview.png)](https://localcdn.de/img/screenshots/screenshot04_dark.png)
### Rule generator for uBlock/uMatrix
<img src="/screenshots/screenshot06.png?raw=true" alt="Release notes and uBlock/uMatrix rule generator" width="200px">
<img src="/screenshots/screenshot07.png?raw=true" alt="Release notes and uBlock/uMatrix rule generator" width="200px">
<img src="/screenshots/screenshot08.png?raw=true" alt="Preferences page and uBlock/uMatrix rule generator" width="200px">
<img src="/screenshots/screenshot09.png?raw=true" alt="Preferences page and uBlock/uMatrix rule generator" width="200px">
[![Release notes and uBlock/uMatrix rule generator](https://localcdn.de/img/screenshots/screenshot06_preview.png)](https://localcdn.de/img/screenshots/screenshot06.png) [![Release notes and uBlock/uMatrix rule generator](https://localcdn.de/img/screenshots/screenshot07_preview.png)](https://localcdn.de/img/screenshots/screenshot07.png) [![Preferences page and uBlock/uMatrix rule generator](https://localcdn.de/img/screenshots/screenshot08_preview.png)](https://localcdn.de/img/screenshots/screenshot08.png) [![Preferences page and uBlock/uMatrix rule generator](https://localcdn.de/img/screenshots/screenshot09_preview.png)](https://localcdn.de/img/screenshots/screenshot09.png)
## Contributing Code
Suggestions in the form of **Issues**, and contributions in the form of **Merge Requests**, are highly welcome.
#### Installation
## Installation
* Mozilla Firefox *(63 or higher)*: [get it on addons.mozilla.org](https://addons.mozilla.org/en-US/firefox/addon/localcdn-fork-of-decentraleyes/)
* Chromium based browser: [Chrome Web Store (by Emanuel Bennici :+1:)](https://chrome.google.com/webstore/detail/localcdn-fork-from-decent/njdfdhgcmkocbgbhcioffdbicglldapd)
* Chromium based browser: [Chrome Web Store (by Emanuel Bennici)](https://chrome.google.com/webstore/detail/localcdn-fork-from-decent/njdfdhgcmkocbgbhcioffdbicglldapd)
#### Running the Code
#### Running the Code as temporary extension
Please read this [developer guide](https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Your_first_WebExtension#Trying_it_out) for information on how to run the extension from source.
@ -86,9 +80,7 @@ Just open an issue with your question or write an [email](https://localcdn.de/co
## Donations
LocalCDN is free, open-source and based on Decentraleyes. If you like LocalCDN and/or Decentraleyes you can support continued development by making a donation. Any help would be greatly appreciated!
* [Donate to LocalCDN](https://localcdn.de/donate/)
* [Donate to Decentraleyes](https://decentraleyes.org/donate)
LocalCDN is free and open-source. If you like LocalCDN you can support continued development by making a donation. Any help would be greatly appreciated! Every way to donate can be found on the [website](https://localcdn.de/donate/). At the moment donations are possible with SEPA bank transfer.
## License

View File

@ -93,16 +93,3 @@ const BrowserType = {
'CHROMIUM': chrome.runtime.getURL("/").startsWith("chrome-extension"),
'FIREFOX': chrome.runtime.getURL("/").startsWith("moz-extension")
};
const CharsetDomains = {
'dejure.org': 'iso-8859-1',
'privacy-handbuch.de': 'iso-8859-1',
'winfuture.de': 'iso-8859-1',
'drwindows.de': 'iso-8859-1',
'sphinx-soft.com': 'iso-8859-1',
'ekaterinaguseva.ru': 'windows-1251',
'hobbybrauerversand.de': 'iso-8859-1',
'pro-linux.de': 'iso-8859-15',
'wwwuser.gwdg.de': 'windows-1252',
'tyurem.net': 'windows-1251'
};

View File

@ -41,34 +41,51 @@ manipulateDOM._getEncoding = function (domain) {
manipulateDOM._removeCrossOriginAndIntegrityAttr = function (details) {
// by Jaap (https://gitlab.com/Jaaap)
// https://gitlab.com/nobody42/localcdn/-/issues/66
let header = details.responseHeaders.find(h => h.name.toLowerCase() === 'content-type');
if (header && BrowserType.FIREFOX) {
let mimeType, charset, initiatorDomain, isWhitelisted;
let mimeType, initiatorDomain, isWhitelisted;
mimeType = header.value.replace(/;.*/, '').toLowerCase();
charset = /charset\s*=/.test(header.value) ? header.value.replace(/^.*?charset\s*=\s*/, '') : 'UTF-8';
initiatorDomain = helpers.extractDomainFromUrl(details.url, true) || Address.EXAMPLE;
isWhitelisted = stateManager._domainIsWhitelisted(initiatorDomain);
if (!isWhitelisted && mimeType === 'text/html') {
let asciiDecoder, decoder, encoder, charset, isFirstData, filter;
asciiDecoder = new TextDecoder('ASCII');
encoder = new TextEncoder();
charset = /charset\s*=/.test(header.value) && header.value.replace(/^.*?charset\s*=\s*/, '');
isFirstData = true;
filter = browser.webRequest.filterResponseData(details.requestId);
header.value = 'text/html; charset=UTF-8';
let decoder = new TextDecoder(manipulateDOM._getEncoding(initiatorDomain));
let encoder = new TextEncoder();
let filter = browser.webRequest.filterResponseData(details.requestId);
//Note that this will not work if the '<script crossorigin="anonymous" src="dfgsfgd.com">' string is divided into two chunks, but we want to flush this data asap.
filter.ondata = evt => {
if (isFirstData) {
if (!charset) {
//content-type has no charset declared
let htmlHead = asciiDecoder.decode(evt.data, {stream: false});
let charsetMatch = htmlHead.match(/<meta\s+charset=["']?([^>"'\/]+)["'>\/]/i);
if (!charsetMatch) {
charsetMatch = htmlHead.match(/<meta\s+http-equiv=["']?content-type["']?\s+content=["']?text\/html;\s+charset=([^>"'\/]+)["'>\/]/i);
}
charset = charsetMatch ? charsetMatch[1] : "UTF-8";
}
decoder = new TextDecoder(charset);
}
//remove crossorigin and integrity attributes
let str = decoder.decode(evt.data, {stream: true}).replace(/<(link|script)[^>]+>/ig, m => {
if (cdnDomainsRE.test(m))
return m.replace(/\s+(integrity|crossorigin)(="[^"]*"|='[^']*'|=[^"'`=\s]+|)/ig, '');
return m;
});
if (cdnDomainsRE.test(m)) {
return m.replace(/\s+(integrity|crossorigin)(="[^"]*"|='[^']*'|=[^"'`=\s]+|)/ig, '');
}
return m;
});
filter.write(encoder.encode(str));
isFirstData = false;
}
filter.onstop = evt => {
@ -104,5 +121,5 @@ manipulateDOM._removeCrossOriginAndIntegrityAttr = function (details) {
chrome.webRequest.onHeadersReceived.addListener(
manipulateDOM._removeCrossOriginAndIntegrityAttr,
{'types': [WebRequestType.MAIN_FRAME], 'urls': [Address.ANY]},
[WebRequest.BLOCKING, WebRequest.RESPONSE_HEADERS]
[WebRequest.BLOCKING, WebRequest.RESPONSE_HEADERS]
);

View File

@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "LocalCDN (fork from Decentraleyes)",
"version": "2.2.1",
"version": "2.2.2",
"browser_specific_settings": {
"gecko": {
"id": "{b86e4813-687a-43e6-ab65-0bde4ab75758}",

View File

@ -179,6 +179,20 @@ footer {
color: #339a6f;
}
#donate-button {
-moz-user-select: none;
user-select: none;
color: #5f5f5f;
cursor: pointer;
float: right;
font-size: 12px;
padding: 5px;
}
#donate-button:hover {
transform: scale(1.3);
}
#options-button-svg,
#donate-button-svg {
background-size: cover;

View File

@ -27,7 +27,7 @@
<img class="icon-logo" src="icon.svg" alt="Extension Icon">
<div class="heading">LocalCDN <sup id="version-label" class="label-version"></sup></div>
<div id="donate-button" class="button">
<div id="donate-button">
<div id="donate-button-svg"></div>
</div>

View File

@ -21,6 +21,27 @@
<div class="subtle-hint">
<div class="topic-label">
New in LocalCDN:
<ul>
<li>Addition to the encoding problem (<a href="https://gitlab.com/nobody42/localcdn/-/issues/75">#75</a>)</li>
</ul>
</div>
<div class="topic-label">
Please update your uBlock/uMatrix rules
</div>
<div class="ruleset-generator">
<input id="generate-ublock-rules" name="rule-sets" data-option="uBlock" type="radio" value="uBlock">
<label for="generate-ublock-rules">uBlock</label>
</div>
<div class="ruleset-generator">
<input id="generate-umatrix-rules" name="rule-sets" data-option="uMatrix" type="radio" value="uMatrix">
<label for="generate-umatrix-rules">uMatrix</label>
</div>
<textarea rows="12" cols="15" id="generated-rules" readonly></textarea>
<input id="button-copy-rule-set" type="button" value="Copy">
<hr/>
<h2>History</h2>
<p class='release-date'>2020-05-16 (v2.2.1)</p>
<ul>
<li>Fixed: Encoding problem with some websites (maybe only temporary, because at the moment only 9 websites are affected) (<a href="https://gitlab.com/nobody42/localcdn/-/issues/75">#75</a>)</li>
<li>Added: Twitter Bootstrap JS and CSS v4.5.0 (<a href="https://gitlab.com/nobody42/localcdn/-/issues/77">#77</a>)</li>
@ -29,7 +50,7 @@
<li>Added: Tether v1.4.7 (<a href="https://gitlab.com/nobody42/localcdn/-/issues/77">#77</a>)</li>
<li>Addition to the encoding problem (<a href="https://gitlab.com/nobody42/localcdn/-/issues/75">#75</a>)</li>
</ul>
</div>
<p class='release-date'>2020-05-10 (v2.2.0)</p>
<ul>
<li>Fixed typo in urlize</li>
<li>Remove crossorigin and integrity attributes (<a href="https://gitlab.com/nobody42/localcdn/-/issues/66">#66</a>) <s>[experimental]</s> <i>It should be working without problems</i></li>
@ -49,21 +70,6 @@
<li>Added Angular Stripe Checkout v5.1.0 (<a href="https://gitlab.com/nobody42/localcdn/-/issues/71">#71</a>)</li>
<li>Fixed error in AngularJS Toaster v0.4.18 (<a href="https://gitlab.com/nobody42/localcdn/-/issues/71">#71</a>)</li>
</ul>
<div class="topic-label">
Please update your uBlock/uMatrix rules
</div>
<div class="ruleset-generator">
<input id="generate-ublock-rules" name="rule-sets" data-option="uBlock" type="radio" value="uBlock">
<label for="generate-ublock-rules">uBlock</label>
</div>
<div class="ruleset-generator">
<input id="generate-umatrix-rules" name="rule-sets" data-option="uMatrix" type="radio" value="uMatrix">
<label for="generate-umatrix-rules">uMatrix</label>
</div>
<textarea rows="12" cols="15" id="generated-rules" readonly></textarea>
<input id="button-copy-rule-set" type="button" value="Copy">
<hr/>
<h2>History</h2>
<p class='release-date'>2020-04-26 (v2.1.14)</p>
<ul>
<li>Added Bootstrap-select v1.13.14</li>