From 329257aba55cce42c56ff37e506bc8ca90ca2fa1 Mon Sep 17 00:00:00 2001 From: nobody Date: Mon, 30 Jan 2023 06:28:07 +0100 Subject: [PATCH] More information about blocked resources (#1309) --- core/interceptor.js | 5 ++++- pages/updates/updates.html | 4 ++++ resources/blocked/blocked.js | 30 ++++++++++++++++++++++++++++++ resources/blocked/index.html | 11 +++++++++++ resources/blocked/style.css | 25 ++++++++++++++++++++++--- 5 files changed, 71 insertions(+), 4 deletions(-) create mode 100644 resources/blocked/blocked.js diff --git a/core/interceptor.js b/core/interceptor.js index a9671908..7d5416f8 100644 --- a/core/interceptor.js +++ b/core/interceptor.js @@ -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}`) }; } diff --git a/pages/updates/updates.html b/pages/updates/updates.html index 241deb43..84563e35 100644 --- a/pages/updates/updates.html +++ b/pages/updates/updates.html @@ -39,6 +39,10 @@ +

Improved

+
diff --git a/resources/blocked/blocked.js b/resources/blocked/blocked.js new file mode 100644 index 00000000..a6a63509 --- /dev/null +++ b/resources/blocked/blocked.js @@ -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; + } + +}) diff --git a/resources/blocked/index.html b/resources/blocked/index.html index 510a8ab1..8a85a7f9 100644 --- a/resources/blocked/index.html +++ b/resources/blocked/index.html @@ -7,9 +7,20 @@ +

This request was blocked because the resource is not included in LocalCDN.

+

+ undefined +

+

+ If you still want to access this resource directly, + you can add the following domain to the "Disable LocalCDN for these domains" list: +

+

+ undefined +

diff --git a/resources/blocked/style.css b/resources/blocked/style.css index ed88ad4f..c5abdb25 100644 --- a/resources/blocked/style.css +++ b/resources/blocked/style.css @@ -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; + } }