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 @@
  • Added: Bootstrap 3 Typeahead v4.0.2 (reported by email)
  • Added: Chart.js (JS-Bundle & CSS) v2.9.3 (reported by email)
  • Improved: Option to enable HTML-Filter by default (#33)
  • +
  • Added: Google Material Icons v3.0.1 (#41)
  • Generate rule sets for uBlock or uMatrix diff --git a/resources/google-material-design-icons/MaterialIcons-Regular.ttf b/resources/google-material-design-icons/MaterialIcons-Regular.ttf new file mode 100644 index 00000000..7015564a Binary files /dev/null and b/resources/google-material-design-icons/MaterialIcons-Regular.ttf differ diff --git a/resources/google-material-design-icons/MaterialIcons-Regular.woff b/resources/google-material-design-icons/MaterialIcons-Regular.woff new file mode 100644 index 00000000..b648a3ee Binary files /dev/null and b/resources/google-material-design-icons/MaterialIcons-Regular.woff differ diff --git a/resources/google-material-design-icons/MaterialIcons-Regular.woff2 b/resources/google-material-design-icons/MaterialIcons-Regular.woff2 new file mode 100644 index 00000000..9fa21125 Binary files /dev/null and b/resources/google-material-design-icons/MaterialIcons-Regular.woff2 differ diff --git a/resources/google-material-design-icons/google-material-design-icons.css b/resources/google-material-design-icons/google-material-design-icons.css new file mode 100644 index 00000000..d6407b02 --- /dev/null +++ b/resources/google-material-design-icons/google-material-design-icons.css @@ -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'; +}