diff --git a/core/interceptor.js b/core/interceptor.js index cca3738e..2ee1407c 100644 --- a/core/interceptor.js +++ b/core/interceptor.js @@ -34,6 +34,12 @@ interceptor.handleRequest = function (requestDetails, tabIdentifier, tab) { let validCandidate, targetDetails, targetDomain, isGoogleFont, isGoogleMaterialIcons, initiatorDomain, isListed; targetDetails = requestAnalyzer.getLocalTarget(requestDetails, tab.url); + if (targetDetails['result'] === 'blocked') { + return { + 'redirectUrl': chrome.runtime.getURL('resources/blocked/index.html') + }; + } + stateManager.requests[requestDetails.requestId] = { tabIdentifier, targetDetails }; diff --git a/core/request-analyzer.js b/core/request-analyzer.js index bc2c96d7..bf85910c 100644 --- a/core/request-analyzer.js +++ b/core/request-analyzer.js @@ -226,6 +226,11 @@ requestAnalyzer._findLocalTarget = function (resourceMappings, basePath, channel console.warn(`${LogString.PREFIX} ${LogString.MISSING_RESOURCE} ${channelHost}${channelPath}`); log.append(initiator, channelHost + channelPath, '-', true); } + + if (Object.keys(mappings.cdn).includes(channelHost)) { + return {'result': 'blocked'}; + } + return { 'result': false, }; diff --git a/pages/updates/updates.html b/pages/updates/updates.html index fefecd7d..c05fae64 100644 --- a/pages/updates/updates.html +++ b/pages/updates/updates.html @@ -25,9 +25,9 @@

New in LocalCDN:

-

+

Improved

diff --git a/resources/blocked/favicon.ico b/resources/blocked/favicon.ico new file mode 100644 index 00000000..7511c74e Binary files /dev/null and b/resources/blocked/favicon.ico differ diff --git a/resources/blocked/index.html b/resources/blocked/index.html new file mode 100644 index 00000000..21d9169b --- /dev/null +++ b/resources/blocked/index.html @@ -0,0 +1,15 @@ + + + + Blocked by LocalCDN + + + + + + + + +

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

+ + diff --git a/resources/blocked/logo.svg b/resources/blocked/logo.svg new file mode 100644 index 00000000..caaab8d1 --- /dev/null +++ b/resources/blocked/logo.svg @@ -0,0 +1,105 @@ + + + +image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/resources/blocked/style.css b/resources/blocked/style.css new file mode 100644 index 00000000..ed88ad4f --- /dev/null +++ b/resources/blocked/style.css @@ -0,0 +1,27 @@ +html { + background-color: #eee; + box-sizing: border-box; +} + +body { + font-size: 1.4em; + text-align: center; + color: #222; + font-family: Helvetica, sans-serif; +} + +.logo { + display: block; + height: 7em; + margin: 3em auto; +} + +@media (prefers-color-scheme: dark) { + html { + background-color: #404040; + } + + body { + color: #aeaeae !important; + } +}