Added Google Material Icons v3.0.1 (#41)

This commit is contained in:
nobody 2020-06-27 11:50:50 +02:00
parent 02e0dc4335
commit 58acfbfdaf
No known key found for this signature in database
GPG Key ID: 8F6DE3D614FCFD7A
10 changed files with 66 additions and 4 deletions

View File

@ -392,6 +392,12 @@ var mappings = {
'algoliasearch@3(algoliasearchLite.min.js),algoliasearch.helper@2': resources.algoliasearchSearchlightHelper
}
},
// Google Material Icons
'fonts.googleapis.com': {
'/': {
'icon?family=Material+Icons': resources.googleMaterialIcons
}
},
// Yandex CDN
'yastatic.net': {
'/': {

View File

@ -57,11 +57,15 @@ requestAnalyzer.isValidCandidate = function (requestDetails, tabDetails) {
requestAnalyzer.getLocalTarget = function (requestDetails) {
let destinationUrl, destinationHost, destinationPath, hostMappings, basePath, resourceMappings;
let destinationSearchString = '';
destinationUrl = new URL(requestDetails.url);
destinationHost = destinationUrl.host;
destinationPath = destinationUrl.pathname;
if (destinationUrl.search) {
destinationSearchString = destinationUrl.search;
}
// Use the proper mappings for the targeted host.
hostMappings = mappings[destinationHost];
@ -79,7 +83,7 @@ requestAnalyzer.getLocalTarget = function (requestDetails) {
}
// Return either the local target's path or false.
return requestAnalyzer._findLocalTarget(resourceMappings, basePath, destinationHost, destinationPath);
return requestAnalyzer._findLocalTarget(resourceMappings, basePath, destinationHost, destinationPath, destinationSearchString);
};
/**
@ -98,7 +102,7 @@ requestAnalyzer._matchBasePath = function (hostMappings, channelPath) {
return false;
};
requestAnalyzer._findLocalTarget = function (resourceMappings, basePath, channelHost, channelPath) {
requestAnalyzer._findLocalTarget = function (resourceMappings, basePath, channelHost, channelPath, destinationSearchString) {
let resourcePath, versionNumber, resourcePattern, filename, shorthandResource;
@ -110,7 +114,7 @@ requestAnalyzer._findLocalTarget = function (resourceMappings, basePath, channel
versionNumber = resourcePath.match(Resource.VERSION_EXPRESSION);
resourcePattern = resourcePath.replace(versionNumber, Resource.VERSION_PLACEHOLDER);
shorthandResource = shorthands.specialFiles(channelHost, channelPath);
shorthandResource = shorthands.specialFiles(channelHost, channelPath, destinationSearchString);
if (shorthandResource) {
if (requestAnalyzer.logging) {
console.log('[ LocalCDN ] Replaced resource: ' + shorthandResource.path);

View File

@ -298,6 +298,11 @@ var resources = {
'path': 'resources/fontawesome/{version}/js/all.min.jsm',
'type': 'application/javascript'
},
// Google Material Icons
'googleMaterialIcons': {
'path': 'resources/google-material-design-icons/google-material-design-icons.css',
'type': 'text/css'
},
// hls.js
'hlsJS': {
'path': 'resources/hls.js/{version}/hls.min.jsm',

View File

@ -85,7 +85,7 @@ shorthands['sdn.geekzu.org'] = shorthands['ajax.googleapis.com'];
// USTC Linux User Group [Mirror]
shorthands['ajax.proxy.ustclug.org'] = shorthands['ajax.googleapis.com'];
shorthands.specialFiles = function (channelHost, channelPath) {
shorthands.specialFiles = function (channelHost, channelPath, searchString) {
/*
NOTE:
jsDelivr allows to load several files in one request
@ -110,6 +110,13 @@ shorthands.specialFiles = function (channelHost, channelPath) {
'path': 'resources/algoliasearch3.33.0_algoliasearchLite_algoliasearchHelper.jsm',
'bundle': ''
};
} else if (channelHost + channelPath + searchString === 'fonts.googleapis.com/icon?family=Material+Icons') {
return {
'source': channelHost,
'version': '3.0.1',
'path': 'resources/google-material-design-icons/google-material-design-icons.css',
'bundle': ''
};
} else {
return false;
}

View File

@ -210,6 +210,8 @@ helpers.determineCdnName = function (domainName) {
return 'NetDNA';
case 'pagecdn.io':
return 'PageCDN';
case 'fonts.googleapis.com':
return 'Google Fonts';
default:
return 'Unknown';
}
@ -527,6 +529,7 @@ helpers.compareVersion = function (v1, v2) {
};
const ListOfFiles = {
'google-material-design-icons.css': 'Google Material Icons',
'Chart.bundle.min.jsm': 'Chart.js (JS)',
'Chart.min.css': 'Chart.js (CSS)',
'bootbox.min.jsm': 'BootboxJS',

View File

@ -42,6 +42,7 @@
<li>Added: Bootstrap 3 Typeahead v4.0.2 (reported by email)</li>
<li>Added: Chart.js (JS-Bundle & CSS) v2.9.3 (reported by email)</li>
<li>Improved: Option to enable HTML-Filter by default (<a href="https://codeberg.org/nobody/LocalCDN/issues/33">#33</a>)</li>
<li>Added: Google Material Icons v3.0.1 (<a href="https://codeberg.org/nobody/LocalCDN/issues/41">#41</a>)</li>
</ul>
<div class="topic-label">
Generate rule sets for uBlock or uMatrix

View File

@ -0,0 +1,36 @@
@font-face {
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
src: url(MaterialIcons-Regular.eot); /* For IE6-8 */
src: local('Material Icons'),
local('MaterialIcons-Regular'),
url('./MaterialIcons-Regular.woff2') format('woff2'),
url('./MaterialIcons-Regular.woff') format('woff'),
url('./MaterialIcons-Regular.ttf') format('truetype');
}
.material-icons {
font-family: 'Material Icons';
font-weight: normal;
font-style: normal;
font-size: 24px; /* Preferred icon size */
display: inline-block;
line-height: 1;
text-transform: none;
letter-spacing: normal;
word-wrap: normal;
white-space: nowrap;
direction: ltr;
/* Support for all WebKit browsers. */
-webkit-font-smoothing: antialiased;
/* Support for Safari and Chrome. */
text-rendering: optimizeLegibility;
/* Support for Firefox. */
-moz-osx-font-smoothing: grayscale;
/* Support for IE. */
font-feature-settings: 'liga';
}