mirror of
https://codeberg.org/nobody/LocalCDN.git
synced 2025-06-05 21:49:31 +02:00
Only open release notes in case of new CDNs (#132)
This commit is contained in:
@@ -55,7 +55,7 @@ main._showReleaseNotes = function (details) {
|
|||||||
|
|
||||||
if (details.reason === chrome.runtime.OnInstalledReason.INSTALL) {
|
if (details.reason === chrome.runtime.OnInstalledReason.INSTALL) {
|
||||||
storageManager.type.set({
|
storageManager.type.set({
|
||||||
[Setting.LAST_MAPPING_UPDATE]: lastMappingUpdate
|
[Setting.LAST_MAPPING_UPDATE]: mappings.lastMappingUpdate
|
||||||
}, function() {
|
}, function() {
|
||||||
if (details.temporary !== true) {
|
if (details.temporary !== true) {
|
||||||
|
|
||||||
@@ -73,12 +73,12 @@ main._showReleaseNotes = function (details) {
|
|||||||
});
|
});
|
||||||
} else if (details.reason === chrome.runtime.OnInstalledReason.UPDATE) {
|
} else if (details.reason === chrome.runtime.OnInstalledReason.UPDATE) {
|
||||||
storageManager.type.get([Setting.LAST_MAPPING_UPDATE, Setting.HIDE_RELEASE_NOTES], function (items) {
|
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) {
|
if (mappingUpdate || !items.hideReleaseNotes) {
|
||||||
// Updated mappings.js
|
// Updated mappings.js
|
||||||
storageManager.type.set({
|
storageManager.type.set({
|
||||||
[Setting.LAST_MAPPING_UPDATE]: lastMappingUpdate
|
[Setting.LAST_MAPPING_UPDATE]: mappings.lastMappingUpdate
|
||||||
}, function() {
|
}, function() {
|
||||||
if (!items.hideReleaseNotes) {
|
if (!items.hideReleaseNotes) {
|
||||||
chrome.tabs.create({
|
chrome.tabs.create({
|
||||||
|
@@ -115,7 +115,7 @@ manipulateDOM._removeCrossOriginAndIntegrityAttr = function (details) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
let whitelistedDomains = {};
|
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('|') + ')/');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -22,14 +22,16 @@
|
|||||||
* Mappings
|
* Mappings
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var mappings = {};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Date of last update.
|
* Date of last update.
|
||||||
* This only needs to be updated when new domains are added.
|
* This only needs to be updated when new domains are added.
|
||||||
* It's not necessary for subdirectories!
|
* It's not necessary for subdirectories!
|
||||||
*/
|
*/
|
||||||
var lastMappingUpdate = "2020-08-24";
|
mappings.lastMappingUpdate = '2020-08-24';
|
||||||
|
|
||||||
var mappings = {
|
mappings.cdn = {
|
||||||
|
|
||||||
// Google Hosted Libraries
|
// Google Hosted Libraries
|
||||||
'ajax.googleapis.com': {
|
'ajax.googleapis.com': {
|
||||||
@@ -827,38 +829,38 @@ var mappings = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Geekzu Public Service [Mirror]
|
// Geekzu Public Service [Mirror]
|
||||||
mappings['sdn.geekzu.org'] = {
|
mappings.cdn['sdn.geekzu.org'] = {
|
||||||
'/ajax/ajax/libs/': mappings['ajax.googleapis.com']['/ajax/libs/']
|
'/ajax/ajax/libs/': mappings.cdn['ajax.googleapis.com']['/ajax/libs/']
|
||||||
};
|
};
|
||||||
|
|
||||||
// USTC Linux User Group [Mirror]
|
// 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)
|
//UNPKG (Cloudflare)
|
||||||
mappings['unpkg.com'] = {
|
mappings.cdn['unpkg.com'] = {
|
||||||
'/': mappings['cdn.jsdelivr.net']['/npm/']
|
'/': mappings.cdn['cdn.jsdelivr.net']['/npm/']
|
||||||
};
|
};
|
||||||
|
|
||||||
// PageCDN
|
// PageCDN
|
||||||
mappings['pagecdn.io'] = {
|
mappings.cdn['pagecdn.io'] = {
|
||||||
'/lib/': mappings['cdnjs.cloudflare.com']['/ajax/libs/']
|
'/lib/': mappings.cdn['cdnjs.cloudflare.com']['/ajax/libs/']
|
||||||
};
|
};
|
||||||
|
|
||||||
// loli.net [Mirror]
|
// loli.net [Mirror]
|
||||||
mappings['cdn.css.net'] = {
|
mappings.cdn['cdn.css.net'] = {
|
||||||
'/lib/': mappings['cdnjs.cloudflare.com']['/ajax/libs/']
|
'/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]
|
// Qihoo 360 CDN [Mirror]
|
||||||
mappings['lib.baomitu.com'] = {
|
mappings.cdn['lib.baomitu.com'] = {
|
||||||
'/': mappings['cdnjs.cloudflare.com']['/ajax/libs/']
|
'/': mappings.cdn['cdnjs.cloudflare.com']['/ajax/libs/']
|
||||||
}
|
}
|
||||||
|
|
||||||
// Boot CDN New [Mirror]
|
// Boot CDN New [Mirror]
|
||||||
mappings['cdn.bootcdn.net'] = mappings['cdnjs.cloudflare.com'];
|
mappings.cdn['cdn.bootcdn.net'] = mappings.cdn['cdnjs.cloudflare.com'];
|
||||||
|
@@ -77,7 +77,7 @@ requestAnalyzer.getLocalTarget = function (requestDetails) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Use the proper mappings for the targeted host.
|
// Use the proper mappings for the targeted host.
|
||||||
hostMappings = mappings[destinationHost];
|
hostMappings = mappings.cdn[destinationHost];
|
||||||
|
|
||||||
// Resource mapping files are never locally available.
|
// Resource mapping files are never locally available.
|
||||||
if (Resource.MAPPING_EXPRESSION.test(destinationPath)) {
|
if (Resource.MAPPING_EXPRESSION.test(destinationPath)) {
|
||||||
|
@@ -278,7 +278,7 @@ stateManager.validHosts = [];
|
|||||||
stateManager.selectedIcon = 'Default';
|
stateManager.selectedIcon = 'Default';
|
||||||
stateManager.internalStatistics = false;
|
stateManager.internalStatistics = false;
|
||||||
|
|
||||||
for (let mapping in mappings) {
|
for (let mapping in mappings.cdn) {
|
||||||
|
|
||||||
let supportedHost = Address.ANY_PROTOCOL + mapping + Address.ANY_PATH;
|
let supportedHost = Address.ANY_PROTOCOL + mapping + Address.ANY_PATH;
|
||||||
stateManager.validHosts.push(supportedHost);
|
stateManager.validHosts.push(supportedHost);
|
||||||
|
@@ -24,7 +24,7 @@ var ruleGenerator = {};
|
|||||||
* Public Methods
|
* Public Methods
|
||||||
*/
|
*/
|
||||||
ruleGenerator.openRuleSet = function ({ target }) {
|
ruleGenerator.openRuleSet = function ({ target }) {
|
||||||
let urls = mappings;
|
let urls = mappings.cdn;
|
||||||
let key = target.getAttribute('data-option');
|
let key = target.getAttribute('data-option');
|
||||||
|
|
||||||
let textArea = document.getElementById('generated-rules');
|
let textArea = document.getElementById('generated-rules');
|
||||||
|
@@ -330,7 +330,7 @@ options._renderInfoPanel = function () {
|
|||||||
btnCDNs.addEventListener('click', options._btnCreateList);
|
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
|
// 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;
|
btnFrameworks.value += Object.keys(options._listOfFrameworks).length - unsupportedFrameworks;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -352,7 +352,7 @@ options._createList = function (type) {
|
|||||||
textArea.value = '';
|
textArea.value = '';
|
||||||
|
|
||||||
if (type === 'cdn') {
|
if (type === 'cdn') {
|
||||||
list = Object.keys(mappings);
|
list = Object.keys(mappings.cdn);
|
||||||
} else if (type === 'framework') {
|
} else if (type === 'framework') {
|
||||||
list = Object.keys(options._listOfFrameworks);
|
list = Object.keys(options._listOfFrameworks);
|
||||||
} else {
|
} else {
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
New in LocalCDN:
|
New in LocalCDN:
|
||||||
</div>
|
</div>
|
||||||
<ul>
|
<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>
|
</ul>
|
||||||
<div id="generator-section">
|
<div id="generator-section">
|
||||||
<div class="topic-label">
|
<div class="topic-label">
|
||||||
|
Reference in New Issue
Block a user