mirror of
https://codeberg.org/nobody/LocalCDN.git
synced 2025-06-05 21:49:31 +02:00
Fixed: Import user settings (#102)
This commit is contained in:
58
core/main.js
58
core/main.js
@ -29,17 +29,14 @@ var main = {};
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
main._initializeSettings = function () {
|
main._initializeSettings = function () {
|
||||||
|
|
||||||
storageManager.checkStorageType();
|
storageManager.checkStorageType();
|
||||||
|
|
||||||
storageManager.type.get(SettingDefaults, function (items) {
|
storageManager.type.get(SettingDefaults, function (items) {
|
||||||
|
|
||||||
if (items === null) {
|
if (items === null) {
|
||||||
items = SettingDefaults; // Restore setting defaults.
|
items = SettingDefaults; // Restore setting defaults.
|
||||||
}
|
}
|
||||||
|
|
||||||
if (items.disablePrefetch !== false) {
|
if (items.disablePrefetch !== false) {
|
||||||
|
|
||||||
chrome.privacy.network.networkPredictionEnabled.set({
|
chrome.privacy.network.networkPredictionEnabled.set({
|
||||||
'value': false
|
'value': false
|
||||||
});
|
});
|
||||||
@ -54,15 +51,12 @@ main._initializeSettings = function () {
|
|||||||
};
|
};
|
||||||
|
|
||||||
main._showReleaseNotes = function (details) {
|
main._showReleaseNotes = function (details) {
|
||||||
|
|
||||||
storageManager.checkStorageType();
|
storageManager.checkStorageType();
|
||||||
|
|
||||||
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]: lastMappingUpdate
|
||||||
}, function() {
|
}, function() {
|
||||||
|
|
||||||
if (details.temporary !== true) {
|
if (details.temporary !== true) {
|
||||||
|
|
||||||
storageManager.type.get([Setting.HIDE_RELEASE_NOTES], function (items) {
|
storageManager.type.get([Setting.HIDE_RELEASE_NOTES], function (items) {
|
||||||
@ -78,45 +72,7 @@ main._showReleaseNotes = function (details) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (details.reason === chrome.runtime.OnInstalledReason.UPDATE) {
|
} else if (details.reason === chrome.runtime.OnInstalledReason.UPDATE) {
|
||||||
|
|
||||||
// ********************************************************************************
|
|
||||||
// TODO: Remove me in v2.4.1
|
|
||||||
let data = '';
|
|
||||||
|
|
||||||
chrome.storage.sync.get(null, function (items) {
|
|
||||||
data = items;
|
|
||||||
|
|
||||||
data['xhrTestDomain'] = 'localcdn.org';
|
|
||||||
data['storageType'] = 'local';
|
|
||||||
data['lastMappingUpdate'] = lastMappingUpdate;
|
|
||||||
|
|
||||||
chrome.storage.local.set({
|
|
||||||
[Setting.ALLOWED_DOMAINS_GOOGLE_FONTS]: data.allowedDomainsGoogleFonts,
|
|
||||||
[Setting.AMOUNT_INJECTED]: data.amountInjected,
|
|
||||||
[Setting.BLOCK_GOOGLE_FONTS]: data.blockGoogleFonts,
|
|
||||||
[Setting.BLOCK_MISSING]: data.blockMissing,
|
|
||||||
[Setting.DISABLE_PREFETCH]: data.disablePrefetch,
|
|
||||||
[Setting.DOMAINS_MANIPULATE_DOM]: data.domainsManipulateDOM,
|
|
||||||
[Setting.LOGGING]: data.logging,
|
|
||||||
[Setting.ENFORCE_STAGING]: data.enforceStaging,
|
|
||||||
[Setting.HIDE_RELEASE_NOTES]: data.hideReleaseNotes,
|
|
||||||
[Setting.INTERNAL_STATISTICS]: data.internalStatistics,
|
|
||||||
[Setting.INTERNAL_STATISTICS_DATA]: data.internalStatisticsData,
|
|
||||||
[Setting.LAST_MAPPING_UPDATE]: data.lastMappingUpdate,
|
|
||||||
[Setting.NEGATE_HTML_FILTER_LIST]: data.negateHtmlFilterList,
|
|
||||||
[Setting.SELECTED_ICON]: data.selectedIcon,
|
|
||||||
[Setting.SHOW_ICON_BADGE]: data.showIconBadge,
|
|
||||||
[Setting.STORAGE_TYPE]: data.storageType,
|
|
||||||
[Setting.STRIP_METADATA]: data.stripMetadata,
|
|
||||||
[Setting.WHITELISTED_DOMAINS]: data.whitelistedDomains,
|
|
||||||
[Setting.XHR_TEST_DOMAIN]: data.xhrTestDomain
|
|
||||||
});
|
|
||||||
});
|
|
||||||
// ********************************************************************************
|
|
||||||
|
|
||||||
// If add-on update true, check last update of mappings.js
|
|
||||||
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 !== lastMappingUpdate;
|
||||||
|
|
||||||
if (mappingUpdate || !items.hideReleaseNotes) {
|
if (mappingUpdate || !items.hideReleaseNotes) {
|
||||||
@ -124,14 +80,14 @@ main._showReleaseNotes = function (details) {
|
|||||||
storageManager.type.set({
|
storageManager.type.set({
|
||||||
[Setting.LAST_MAPPING_UPDATE]: lastMappingUpdate
|
[Setting.LAST_MAPPING_UPDATE]: lastMappingUpdate
|
||||||
}, function() {
|
}, function() {
|
||||||
|
if (!items.hideReleaseNotes) {
|
||||||
|
// ********************************************************************************
|
||||||
|
// TODO: Change me in v2.4.1
|
||||||
|
// chrome.tabs.create({
|
||||||
|
// 'url': chrome.extension.getURL('pages/updates/updates.html?mappingupdate=' + mappingUpdate),
|
||||||
|
// 'active': false
|
||||||
|
// });
|
||||||
// ********************************************************************************
|
// ********************************************************************************
|
||||||
// TODO: Remove me in v2.4.1
|
|
||||||
// if (!items.hideReleaseNotes) {
|
|
||||||
if (true) {
|
|
||||||
chrome.tabs.create({
|
|
||||||
'url': chrome.extension.getURL('pages/updates/updates.html?mappingupdate=' + mappingUpdate),
|
|
||||||
'active': false
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
25
core/migrate.js
Normal file
25
core/migrate.js
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
// ********************************************************************************
|
||||||
|
// TODO: Remove me in v2.4.1
|
||||||
|
chrome.runtime.onInstalled.addListener(function(details) {
|
||||||
|
if (details.reason === chrome.runtime.OnInstalledReason.UPDATE) {
|
||||||
|
chrome.storage.sync.get(null, function(items) {
|
||||||
|
// Workaround for https://codeberg.org/nobody/LocalCDN/issues/102
|
||||||
|
setTimeout(function() {
|
||||||
|
chrome.storage.local.set(items, function() {
|
||||||
|
chrome.runtime.reload();
|
||||||
|
});
|
||||||
|
}, 5000);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
chrome.storage.local.get('extensionReloaded', function(items) {
|
||||||
|
if (!('extensionReloaded' in items)) {
|
||||||
|
chrome.tabs.create({
|
||||||
|
'url': chrome.extension.getURL('pages/updates/updates.html?mappingupdate=true'),
|
||||||
|
'active': false
|
||||||
|
});
|
||||||
|
chrome.storage.local.set({'extensionReloaded': true});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// ********************************************************************************
|
@ -5,6 +5,12 @@
|
|||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<!-- ********************************************************************************
|
||||||
|
TODO: Remove me in v2.4.1
|
||||||
|
-->
|
||||||
|
<script src="../../core/migrate.js"></script>
|
||||||
|
<!-- ******************************************************************************** -->
|
||||||
|
|
||||||
<script src="../../core/constants.js"></script>
|
<script src="../../core/constants.js"></script>
|
||||||
<script src="../../core/storage-manager.js"></script>
|
<script src="../../core/storage-manager.js"></script>
|
||||||
|
|
||||||
|
@ -49,6 +49,7 @@
|
|||||||
<li>Added: jQuery Easing Plugin v1.4.1 (<a href="https://codeberg.org/nobody/LocalCDN/issues/101">#101</a>)</li>
|
<li>Added: jQuery Easing Plugin v1.4.1 (<a href="https://codeberg.org/nobody/LocalCDN/issues/101">#101</a>)</li>
|
||||||
<li>Updated: popper.js v2.4.4 (<a href="https://codeberg.org/nobody/LocalCDN/issues/103">#103</a>)</li>
|
<li>Updated: popper.js v2.4.4 (<a href="https://codeberg.org/nobody/LocalCDN/issues/103">#103</a>)</li>
|
||||||
<li>Added: AnchorJS v3.2.2 & v4.2.2 (<a href="https://codeberg.org/nobody/LocalCDN/issues/104">#104</a>)</li>
|
<li>Added: AnchorJS v3.2.2 & v4.2.2 (<a href="https://codeberg.org/nobody/LocalCDN/issues/104">#104</a>)</li>
|
||||||
|
<li>Fixed: Import user settings (<a href="https://codeberg.org/nobody/LocalCDN/issues/102">#102</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