Custom block screen (#1050)

This commit is contained in:
nobody 2022-07-10 06:55:41 +02:00
parent be16dbe84c
commit 1be3c1cf6d
No known key found for this signature in database
GPG Key ID: 8F6DE3D614FCFD7A
7 changed files with 160 additions and 2 deletions

View File

@ -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
};

View File

@ -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,
};

View File

@ -25,9 +25,9 @@
<h2>New in LocalCDN:</h2>
</div>
<div class="release-notes-area">
<p></p>
<p>Improved</p>
<ul>
<li></li>
<li>Custom block screen (<a href="https://codeberg.org/nobody/LocalCDN/issues/1050">#1050</a>)</li>
</ul>
</div>
<div id="generator-section">

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Blocked by LocalCDN</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<link rel="icon" href="favicon.ico" type="image/x-icon">
<link rel="stylesheet" href="style.css">
</head>
<body>
<img src="logo.svg" alt="LocalCDN" class="logo"/>
<p>This request was blocked because the resource is not included in LocalCDN.</p>
</body>
</html>

105
resources/blocked/logo.svg Normal file
View File

@ -0,0 +1,105 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Generator: Adobe Illustrator 18.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
id="Capa_1"
x="0px"
y="0px"
viewBox="0 0 294.361 294.361"
style="enable-background:new 0 0 294.361 294.361;"
xml:space="preserve"
sodipodi:docname="security-svgrepo-com.svg"
inkscape:version="0.92.3 (2405546, 2018-03-11)"><metadata
id="metadata2411"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs
id="defs2409" /><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1680"
inkscape:window-height="997"
id="namedview2407"
showgrid="false"
inkscape:zoom="0.80173666"
inkscape:cx="147.1805"
inkscape:cy="147.1805"
inkscape:window-x="0"
inkscape:window-y="25"
inkscape:window-maximized="1"
inkscape:current-layer="Capa_1" />
<g
id="g2374"
style="fill:#058300;fill-opacity:1">
<path
d="M154.444,127.639l26.045,26.044c6.639-18.818,11.328-38.756,13.101-56.781c0.06-0.608-0.276-1.16-0.835-1.373 l-70.484-26.933c-0.152-0.058-0.312-0.088-0.475-0.088c-0.163,0-0.323,0.029-0.475,0.088L50.836,95.529 c-0.551,0.21-0.894,0.775-0.835,1.373c2.922,29.705,13.73,64.62,28.206,91.12c14.162,25.923,30.457,41.4,43.589,41.4 c5.948,0,12.545-3.184,19.298-9.067l-39.684-39.683c-14.644-14.645-14.644-38.388,0-53.033 C116.056,112.995,139.8,112.995,154.444,127.639z"
id="path2368"
style="fill:#058300;fill-opacity:1" />
<path
d="M155.255,234.516c-10.37,9.333-21.651,14.906-33.459,14.906c-46.932,0-85.544-87.976-91.7-150.562 c-0.94-9.56,4.627-18.585,13.6-22.013l70.486-26.933c2.451-0.937,5.032-1.405,7.614-1.405c2.581,0,5.162,0.468,7.613,1.405 l70.484,26.932c8.987,3.434,14.542,12.439,13.6,22.014c-0.969,9.846-2.742,20.322-5.223,30.984l34.029-34.029 c0.432-2.986,0.814-5.947,1.129-8.869c1.339-12.425-5.599-24.245-17.109-29.112L132.822,18.3c-7.048-2.98-15.002-2.98-22.05,0 L17.273,57.833C5.777,62.694-1.174,74.535,0.164,86.945c8.821,81.833,64.496,191.35,121.633,191.35 c19.371,0,38.571-12.598,55.837-32.427c-7.931-1.024-15.598-4.572-21.69-10.664L155.255,234.516z"
id="path2370"
style="fill:#058300;fill-opacity:1" />
<path
d="M288.504,102.645c-7.811-7.811-20.475-7.811-28.285,0l-77.758,77.759l-40.392-40.391 c-7.811-7.811-20.474-7.81-28.284,0.001c-7.811,7.811-7.809,20.474,0.001,28.284l54.533,54.532 c3.905,3.905,9.023,5.857,14.142,5.857c5.118,0,10.237-1.952,14.143-5.857l91.9-91.9 C296.313,123.12,296.313,110.456,288.504,102.645z"
id="path2372"
style="fill:#058300;fill-opacity:1" />
</g>
<g
id="g2376">
</g>
<g
id="g2378">
</g>
<g
id="g2380">
</g>
<g
id="g2382">
</g>
<g
id="g2384">
</g>
<g
id="g2386">
</g>
<g
id="g2388">
</g>
<g
id="g2390">
</g>
<g
id="g2392">
</g>
<g
id="g2394">
</g>
<g
id="g2396">
</g>
<g
id="g2398">
</g>
<g
id="g2400">
</g>
<g
id="g2402">
</g>
<g
id="g2404">
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

@ -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;
}
}