More information about blocked resources (#1309)

This commit is contained in:
nobody 2023-01-30 06:28:07 +01:00
parent dcda699d31
commit 329257aba5
No known key found for this signature in database
GPG Key ID: 8F6DE3D614FCFD7A
5 changed files with 71 additions and 4 deletions

View File

@ -52,8 +52,11 @@ interceptor.handleRequest = function (requestDetails, tabIdentifier, tab) {
targetDetails = requestAnalyzer.getLocalTarget(requestDetails, tab.url);
if (targetDetails['result'] === 'blocked') {
let source, resource;
source = helpers.extractDomainFromUrl(tab.url, true);
resource = tab.url;
return {
'redirectUrl': chrome.runtime.getURL('resources/blocked/index.html')
'redirectUrl': chrome.runtime.getURL(`resources/blocked/index.html?source=${source}&resource=${resource}`)
};
}

View File

@ -39,6 +39,10 @@
<ul>
<li>cdnjs.com -> Some angular modules (<a href="https://codeberg.org/nobody/LocalCDN/issues/1307">#1307</a>)</li>
</ul>
<p>Improved</p>
<ul>
<li>More information about blocked resources (<a href="https://codeberg.org/nobody/LocalCDN/issues/1309">#1309</a>)</li>
</ul>
</div>
<div id="generator-section">
<div class="topic-label">

View File

@ -0,0 +1,30 @@
/**
* Inserts data into the fields of the blocking page
*
* @author nobody
* @since 2023-01-30
*
* @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/.
*/
window.addEventListener('load', function () {
let parameters, source, resource;
parameters = new URLSearchParams(window.location.search);
source = parameters.get('source');
resource = parameters.get('resource');
if (source) {
document.getElementById("source").textContent = source;
}
if (resource) {
document.getElementById("resource").textContent = resource;
}
})

View File

@ -7,9 +7,20 @@
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<link rel="icon" href="favicon.ico" type="image/x-icon">
<link rel="stylesheet" type="text/css" href="style.css">
<script src="blocked.js"></script>
</head>
<body>
<img src="logo.svg" alt="LocalCDN" class="logo"/>
<p>This request was blocked because the resource is not included in LocalCDN.</p>
<p>
<span id="resource" class="url">undefined</span>
</p>
<p class="details">
If you still want to access this resource directly,
you can add the following domain to the "Disable LocalCDN for these domains" list:
</p>
<p>
<span id="source" class="url">undefined</span>
</p>
</body>
</html>

View File

@ -1,13 +1,20 @@
html {
background-color: #eee;
background-color: #ddd;
box-sizing: border-box;
}
body {
font-size: 1.4em;
text-align: center;
color: #222;
font-family: Helvetica, sans-serif;
font-size: 1.4em;
margin-left: auto;
margin-right: auto;
max-width: 800px;
text-align: center;
}
.details {
margin-top: 4em;
}
.logo {
@ -16,6 +23,14 @@ body {
margin: 3em auto;
}
.url {
background-color: #eee;
border: 1px solid #bfbfbf;
border-radius: 5px;
font-family: monospace;
padding: 10px;
}
@media (prefers-color-scheme: dark) {
html {
background-color: #404040;
@ -24,4 +39,8 @@ body {
body {
color: #aeaeae !important;
}
.url {
background-color: #383838;
}
}