mirror of
https://codeberg.org/nobody/LocalCDN.git
synced 2025-02-16 20:00:57 +01:00
Block bad resources (#703)
This commit is contained in:
parent
f4daff688f
commit
e0f8719391
@ -31,6 +31,7 @@
|
|||||||
"BadgeSetting": true,
|
"BadgeSetting": true,
|
||||||
"BadgeSettingHTMLFilter": true,
|
"BadgeSettingHTMLFilter": true,
|
||||||
"BadgeSettingMissingResource": true,
|
"BadgeSettingMissingResource": true,
|
||||||
|
"BadResources": true,
|
||||||
|
|
||||||
"fileGuard": true,
|
"fileGuard": true,
|
||||||
"files": true,
|
"files": true,
|
||||||
|
@ -391,6 +391,20 @@ const MathJaxFiles = {
|
|||||||
'jax/output/HTML-CSS/jax.js': true,
|
'jax/output/HTML-CSS/jax.js': true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To block bad resources, e.g. fingerprint
|
||||||
|
*
|
||||||
|
* Necessary if the user has selected the option "Block requests for missing
|
||||||
|
* resources Advanced" option is not enabled.
|
||||||
|
*
|
||||||
|
* https://codeberg.org/nobody/LocalCDN/issues/703
|
||||||
|
*/
|
||||||
|
const BadResources = {
|
||||||
|
'cdn.jsdelivr.net/npm/@fingerprintjs/': true,
|
||||||
|
'cdnjs.cloudflare.com/ajax/libs/fingerprintjs/': true,
|
||||||
|
'cdnjs.cloudflare.com/ajax/libs/fingerprintjs2/': true,
|
||||||
|
'cdnjs.cloudflare.com/ajax/libs/ClientJS/': true,
|
||||||
|
};
|
||||||
|
|
||||||
// Supported charsets for TextDecoder()
|
// Supported charsets for TextDecoder()
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder/TextDecoder
|
// https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder/TextDecoder
|
||||||
|
@ -41,6 +41,14 @@ interceptor.handleRequest = function (requestDetails, tabIdentifier, tab) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!interceptor.blockMissing && interceptor._isBadResource(requestDetails.url)) {
|
||||||
|
console.warn(`[ LocalCDN ] Evil resource blocked: ${requestDetails.url}`);
|
||||||
|
log.append(tab.url, requestDetails.url, '-', true);
|
||||||
|
return {
|
||||||
|
'cancel': true
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
targetDetails = requestAnalyzer.getLocalTarget(requestDetails, tab.url);
|
targetDetails = requestAnalyzer.getLocalTarget(requestDetails, tab.url);
|
||||||
targetPath = targetDetails.path;
|
targetPath = targetDetails.path;
|
||||||
|
|
||||||
@ -141,6 +149,10 @@ interceptor._handleStorageChanged = function (changes) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
interceptor._isBadResource = function (requestUrl) {
|
||||||
|
requestUrl = requestUrl.replace(/(^\w+:|^)\/\//, '');
|
||||||
|
return Object.keys(BadResources).filter((path) => requestUrl.startsWith(path)).length !== 0;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event Handlers
|
* Event Handlers
|
||||||
|
@ -33,6 +33,10 @@
|
|||||||
<li>vue-i18n v8.26.1 -> v8.26.2 (<a href="https://codeberg.org/nobody/LocalCDN/issues/701">#701</a>)</li>
|
<li>vue-i18n v8.26.1 -> v8.26.2 (<a href="https://codeberg.org/nobody/LocalCDN/issues/701">#701</a>)</li>
|
||||||
<li>findify-bundle v7.1.3 -> v7.1.6 (<a href="https://codeberg.org/nobody/LocalCDN/issues/702">#702</a>)</li>
|
<li>findify-bundle v7.1.3 -> v7.1.6 (<a href="https://codeberg.org/nobody/LocalCDN/issues/702">#702</a>)</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
<p>Improved</p>
|
||||||
|
<ul>
|
||||||
|
<li>Block bad resources (<a href="https://codeberg.org/nobody/LocalCDN/issues/703">#703</a>)</li>
|
||||||
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div id="generator-section">
|
<div id="generator-section">
|
||||||
<div class="topic-label">
|
<div class="topic-label">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user