diff --git a/core/mappings.js b/core/mappings.js index cc937893..0237c97e 100644 --- a/core/mappings.js +++ b/core/mappings.js @@ -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': { '/': { diff --git a/core/request-analyzer.js b/core/request-analyzer.js index e2cbc248..4e9a69de 100644 --- a/core/request-analyzer.js +++ b/core/request-analyzer.js @@ -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); diff --git a/core/resources.js b/core/resources.js index 9d7f3db2..63ce8e74 100644 --- a/core/resources.js +++ b/core/resources.js @@ -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', diff --git a/core/shorthands.js b/core/shorthands.js index 59970af1..30eab038 100644 --- a/core/shorthands.js +++ b/core/shorthands.js @@ -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; } diff --git a/modules/internal/helpers.js b/modules/internal/helpers.js index fa034d0b..61597900 100644 --- a/modules/internal/helpers.js +++ b/modules/internal/helpers.js @@ -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', diff --git a/pages/updates/updates.html b/pages/updates/updates.html index 3d491c91..934c6424 100644 --- a/pages/updates/updates.html +++ b/pages/updates/updates.html @@ -42,6 +42,7 @@