1
0
mirror of https://codeberg.org/nobody/LocalCDN.git synced 2024-12-23 00:25:15 +01:00

Only open release notes in case of new CDNs (#132)

This commit is contained in:
nobody 2020-10-11 12:52:17 +02:00
parent 3bb3657855
commit 1a97b72039
No known key found for this signature in database
GPG Key ID: 8F6DE3D614FCFD7A
8 changed files with 29 additions and 27 deletions

View File

@ -55,7 +55,7 @@ main._showReleaseNotes = function (details) {
if (details.reason === chrome.runtime.OnInstalledReason.INSTALL) {
storageManager.type.set({
[Setting.LAST_MAPPING_UPDATE]: lastMappingUpdate
[Setting.LAST_MAPPING_UPDATE]: mappings.lastMappingUpdate
}, function() {
if (details.temporary !== true) {
@ -73,12 +73,12 @@ main._showReleaseNotes = function (details) {
});
} else if (details.reason === chrome.runtime.OnInstalledReason.UPDATE) {
storageManager.type.get([Setting.LAST_MAPPING_UPDATE, Setting.HIDE_RELEASE_NOTES], function (items) {
let mappingUpdate = items.lastMappingUpdate !== lastMappingUpdate;
let mappingUpdate = items.lastMappingUpdate !== mappings.lastMappingUpdate;
if (mappingUpdate || !items.hideReleaseNotes) {
// Updated mappings.js
storageManager.type.set({
[Setting.LAST_MAPPING_UPDATE]: lastMappingUpdate
[Setting.LAST_MAPPING_UPDATE]: mappings.lastMappingUpdate
}, function() {
if (!items.hideReleaseNotes) {
chrome.tabs.create({

View File

@ -115,7 +115,7 @@ manipulateDOM._removeCrossOriginAndIntegrityAttr = function (details) {
*/
let whitelistedDomains = {};
let cdnDomainsRE = new RegExp('//(' + Object.keys(mappings).map(m => m.replace(/\W/g, '\\$&')).join('|') + ')/');
let cdnDomainsRE = new RegExp('//(' + Object.keys(mappings.cdn).map(m => m.replace(/\W/g, '\\$&')).join('|') + ')/');
/**

View File

@ -22,14 +22,16 @@
* Mappings
*/
var mappings = {};
/*
* Date of last update.
* This only needs to be updated when new domains are added.
* It's not necessary for subdirectories!
*/
var lastMappingUpdate = "2020-08-24";
mappings.lastMappingUpdate = '2020-08-24';
var mappings = {
mappings.cdn = {
// Google Hosted Libraries
'ajax.googleapis.com': {
@ -827,38 +829,38 @@ var mappings = {
};
// Geekzu Public Service [Mirror]
mappings['sdn.geekzu.org'] = {
'/ajax/ajax/libs/': mappings['ajax.googleapis.com']['/ajax/libs/']
mappings.cdn['sdn.geekzu.org'] = {
'/ajax/ajax/libs/': mappings.cdn['ajax.googleapis.com']['/ajax/libs/']
};
// USTC Linux User Group [Mirror]
mappings['ajax.proxy.ustclug.org'] = mappings['ajax.googleapis.com'];
mappings.cdn['ajax.proxy.ustclug.org'] = mappings.cdn['ajax.googleapis.com'];
//UNPKG (Cloudflare)
mappings['unpkg.com'] = {
'/': mappings['cdn.jsdelivr.net']['/npm/']
mappings.cdn['unpkg.com'] = {
'/': mappings.cdn['cdn.jsdelivr.net']['/npm/']
};
// PageCDN
mappings['pagecdn.io'] = {
'/lib/': mappings['cdnjs.cloudflare.com']['/ajax/libs/']
mappings.cdn['pagecdn.io'] = {
'/lib/': mappings.cdn['cdnjs.cloudflare.com']['/ajax/libs/']
};
// loli.net [Mirror]
mappings['cdn.css.net'] = {
'/lib/': mappings['cdnjs.cloudflare.com']['/ajax/libs/']
mappings.cdn['cdn.css.net'] = {
'/lib/': mappings.cdn['cdnjs.cloudflare.com']['/ajax/libs/']
};
mappings['cdnjs.loli.net'] = mappings['cdnjs.cloudflare.com'];
mappings.cdn['cdnjs.loli.net'] = mappings.cdn['cdnjs.cloudflare.com'];
mappings['ajax.loli.net'] = mappings['ajax.googleapis.com'];
mappings.cdn['ajax.loli.net'] = mappings.cdn['ajax.googleapis.com'];
mappings['fonts.loli.net'] = mappings['fonts.googleapis.com'];
mappings.cdn['fonts.loli.net'] = mappings.cdn['fonts.googleapis.com'];
// Qihoo 360 CDN [Mirror]
mappings['lib.baomitu.com'] = {
'/': mappings['cdnjs.cloudflare.com']['/ajax/libs/']
mappings.cdn['lib.baomitu.com'] = {
'/': mappings.cdn['cdnjs.cloudflare.com']['/ajax/libs/']
}
// Boot CDN New [Mirror]
mappings['cdn.bootcdn.net'] = mappings['cdnjs.cloudflare.com'];
mappings.cdn['cdn.bootcdn.net'] = mappings.cdn['cdnjs.cloudflare.com'];

View File

@ -77,7 +77,7 @@ requestAnalyzer.getLocalTarget = function (requestDetails) {
}
// Use the proper mappings for the targeted host.
hostMappings = mappings[destinationHost];
hostMappings = mappings.cdn[destinationHost];
// Resource mapping files are never locally available.
if (Resource.MAPPING_EXPRESSION.test(destinationPath)) {

View File

@ -278,7 +278,7 @@ stateManager.validHosts = [];
stateManager.selectedIcon = 'Default';
stateManager.internalStatistics = false;
for (let mapping in mappings) {
for (let mapping in mappings.cdn) {
let supportedHost = Address.ANY_PROTOCOL + mapping + Address.ANY_PATH;
stateManager.validHosts.push(supportedHost);

View File

@ -24,7 +24,7 @@ var ruleGenerator = {};
* Public Methods
*/
ruleGenerator.openRuleSet = function ({ target }) {
let urls = mappings;
let urls = mappings.cdn;
let key = target.getAttribute('data-option');
let textArea = document.getElementById('generated-rules');

View File

@ -330,7 +330,7 @@ options._renderInfoPanel = function () {
btnCDNs.addEventListener('click', options._btnCreateList);
// Reduce CDNs by 3, because loli.net includes = cdn.css.net, cdnjs.loli.net, ajax.loli.net, fonts.loli.net
btnCDNs.value += Object.keys(mappings).length - 3;
btnCDNs.value += Object.keys(mappings.cdn).length - 3;
btnFrameworks.value += Object.keys(options._listOfFrameworks).length - unsupportedFrameworks;
};
@ -352,7 +352,7 @@ options._createList = function (type) {
textArea.value = '';
if (type === 'cdn') {
list = Object.keys(mappings);
list = Object.keys(mappings.cdn);
} else if (type === 'framework') {
list = Object.keys(options._listOfFrameworks);
} else {

View File

@ -25,7 +25,7 @@
New in LocalCDN:
</div>
<ul>
<li></li>
<li>Fixed: Only open release notes in case of new CDNs (<a href="https://codeberg.org/nobody/LocalCDN/issues/132">#132</a>)</li>
</ul>
<div id="generator-section">
<div class="topic-label">