mirror of
https://codeberg.org/nobody/LocalCDN.git
synced 2024-12-23 00:25:15 +01:00
Implemented Sync extension settings with Firefox Sync or own server (experimental)
This commit is contained in:
parent
f87c77f325
commit
f7b85adc24
@ -137,7 +137,7 @@ interceptor.relatedSettings.push(Setting.AMOUNT_INJECTED);
|
||||
interceptor.relatedSettings.push(Setting.XHR_TEST_DOMAIN);
|
||||
interceptor.relatedSettings.push(Setting.BLOCK_MISSING);
|
||||
|
||||
chrome.storage.local.get(interceptor.relatedSettings, function (items) {
|
||||
chrome.storage.sync.get(interceptor.relatedSettings, function (items) {
|
||||
|
||||
interceptor.amountInjected = items.amountInjected || 0;
|
||||
interceptor.xhrTestDomain = items.xhrTestDomain || Address.DECENTRALEYES;
|
||||
|
12
core/main.js
12
core/main.js
@ -38,7 +38,7 @@ main._initializeSettings = function () {
|
||||
[Setting.DOMAINS_MANIPULATE_DOM]: {}
|
||||
};
|
||||
|
||||
chrome.storage.local.get(settingDefaults, function (items) {
|
||||
chrome.storage.sync.get(settingDefaults, function (items) {
|
||||
|
||||
if (items === null) {
|
||||
items = settingDefaults; // Restore setting defaults.
|
||||
@ -57,7 +57,7 @@ main._initializeSettings = function () {
|
||||
});
|
||||
}
|
||||
|
||||
chrome.storage.local.set(items);
|
||||
chrome.storage.sync.set(items);
|
||||
});
|
||||
};
|
||||
|
||||
@ -70,7 +70,7 @@ main._showReleaseNotes = function (details) {
|
||||
|
||||
if (details.reason === chrome.runtime.OnInstalledReason.INSTALL) {
|
||||
|
||||
chrome.storage.local.set({
|
||||
chrome.storage.sync.set({
|
||||
[Setting.LAST_MAPPING_UPDATE]: lastMappingUpdate
|
||||
}, function() {
|
||||
|
||||
@ -82,7 +82,7 @@ main._showReleaseNotes = function (details) {
|
||||
|
||||
if (details.temporary !== true) {
|
||||
|
||||
chrome.storage.local.get([Setting.HIDE_RELEASE_NOTES], function (items) {
|
||||
chrome.storage.sync.get([Setting.HIDE_RELEASE_NOTES], function (items) {
|
||||
|
||||
if (items.hideReleaseNotes !== true) {
|
||||
|
||||
@ -100,13 +100,13 @@ main._showReleaseNotes = function (details) {
|
||||
let oldValue = "";
|
||||
|
||||
// If add-on update true, check last update of mappings.js
|
||||
chrome.storage.local.get([Setting.LAST_MAPPING_UPDATE, Setting.HIDE_RELEASE_NOTES], function (items) {
|
||||
chrome.storage.sync.get([Setting.LAST_MAPPING_UPDATE, Setting.HIDE_RELEASE_NOTES], function (items) {
|
||||
|
||||
oldValue = items.lastMappingUpdate;
|
||||
|
||||
if (oldValue !== newValue) {
|
||||
// Updated mappings.js
|
||||
chrome.storage.local.set({
|
||||
chrome.storage.sync.set({
|
||||
[Setting.LAST_MAPPING_UPDATE]: newValue
|
||||
}, function() {
|
||||
if (!items.hideReleaseNotes) {
|
||||
|
@ -102,7 +102,7 @@ requestAnalyzer._findLocalTarget = function (resourceMappings, basePath, channel
|
||||
|
||||
let resourcePath, versionNumber, resourcePattern, filename, shorthandResource;
|
||||
|
||||
chrome.storage.local.get(Setting.LOGGING, function (items) {
|
||||
chrome.storage.sync.get(Setting.LOGGING, function (items) {
|
||||
requestAnalyzer.logging = items.enableLogging;
|
||||
});
|
||||
|
||||
@ -168,13 +168,13 @@ requestAnalyzer._findLocalTarget = function (resourceMappings, basePath, channel
|
||||
|
||||
requestAnalyzer._applyWhitelistedDomains = function () {
|
||||
|
||||
chrome.storage.local.get(Setting.WHITELISTED_DOMAINS, function (items) {
|
||||
chrome.storage.sync.get(Setting.WHITELISTED_DOMAINS, function (items) {
|
||||
requestAnalyzer.whitelistedDomains = items.whitelistedDomains || {};
|
||||
});
|
||||
};
|
||||
requestAnalyzer._applyManipulateDOMDomains = function () {
|
||||
|
||||
chrome.storage.local.get(Setting.DOMAINS_MANIPULATE_DOM, function (items) {
|
||||
chrome.storage.sync.get(Setting.DOMAINS_MANIPULATE_DOM, function (items) {
|
||||
requestAnalyzer.domainsManipulateDOM = items.domainsManipulateDOM || {};
|
||||
});
|
||||
};
|
||||
|
@ -65,7 +65,7 @@ requestSanitizer._stripMetadata = function (requestDetails) {
|
||||
* Initializations
|
||||
*/
|
||||
|
||||
chrome.storage.local.get({[Setting.STRIP_METADATA]: true}, function (items) {
|
||||
chrome.storage.sync.get({[Setting.STRIP_METADATA]: true}, function (items) {
|
||||
|
||||
if (items === null || items.stripMetadata !== false) {
|
||||
requestSanitizer.enable();
|
||||
|
@ -55,18 +55,18 @@ stateManager.registerInjection = function (tabIdentifier, injection) {
|
||||
|
||||
if (isNaN(interceptor.amountInjected)) {
|
||||
|
||||
chrome.storage.local.get(Setting.AMOUNT_INJECTED, function (items) {
|
||||
chrome.storage.sync.get(Setting.AMOUNT_INJECTED, function (items) {
|
||||
|
||||
interceptor.amountInjected = items.amountInjected;
|
||||
|
||||
chrome.storage.local.set({
|
||||
chrome.storage.sync.set({
|
||||
[Setting.AMOUNT_INJECTED]: ++interceptor.amountInjected
|
||||
});
|
||||
});
|
||||
|
||||
} else {
|
||||
|
||||
chrome.storage.local.set({
|
||||
chrome.storage.sync.set({
|
||||
[Setting.AMOUNT_INJECTED]: ++interceptor.amountInjected
|
||||
});
|
||||
}
|
||||
@ -94,7 +94,7 @@ stateManager.updateEnvironment = function (preferredEnvironment) {
|
||||
|
||||
let requiredItems = [Setting.BLOCK_MISSING, Setting.ENFORCE_STAGING];
|
||||
|
||||
chrome.storage.local.get(requiredItems, function (items) {
|
||||
chrome.storage.sync.get(requiredItems, function (items) {
|
||||
|
||||
if (items.blockMissing === true || items.enforceStaging === true) {
|
||||
stateManager.setEnvironment(Environment.STAGING);
|
||||
@ -120,7 +120,7 @@ stateManager.addDomainToWhitelist = function (domain) {
|
||||
let whitelistedDomains = requestAnalyzer.whitelistedDomains;
|
||||
whitelistedDomains[domain] = true;
|
||||
|
||||
chrome.storage.local.set({whitelistedDomains}, resolve);
|
||||
chrome.storage.sync.set({whitelistedDomains}, resolve);
|
||||
});
|
||||
};
|
||||
|
||||
@ -131,7 +131,7 @@ stateManager.removeDomainFromWhitelist = function (domain) {
|
||||
let whitelistedDomains = requestAnalyzer.whitelistedDomains;
|
||||
delete whitelistedDomains[domain];
|
||||
|
||||
chrome.storage.local.set({whitelistedDomains}, resolve);
|
||||
chrome.storage.sync.set({whitelistedDomains}, resolve);
|
||||
});
|
||||
};
|
||||
|
||||
@ -142,7 +142,7 @@ stateManager.addDomainToManipulateDOMlist = function (domain) {
|
||||
let domainsManipulateDOM = requestAnalyzer.domainsManipulateDOM;
|
||||
domainsManipulateDOM[domain] = true;
|
||||
|
||||
chrome.storage.local.set({domainsManipulateDOM}, resolve);
|
||||
chrome.storage.sync.set({domainsManipulateDOM}, resolve);
|
||||
});
|
||||
};
|
||||
|
||||
@ -153,7 +153,7 @@ stateManager.removeDomainFromManipulateDOMlist = function (domain) {
|
||||
let domainsManipulateDOM = requestAnalyzer.domainsManipulateDOM;
|
||||
delete domainsManipulateDOM[domain];
|
||||
|
||||
chrome.storage.local.set({domainsManipulateDOM}, resolve);
|
||||
chrome.storage.sync.set({domainsManipulateDOM}, resolve);
|
||||
});
|
||||
};
|
||||
|
||||
@ -339,7 +339,7 @@ chrome.tabs.query({}, function (tabs) {
|
||||
tabs.forEach(stateManager._createTab);
|
||||
});
|
||||
|
||||
chrome.storage.local.get(Setting.SHOW_ICON_BADGE, function (items) {
|
||||
chrome.storage.sync.get(Setting.SHOW_ICON_BADGE, function (items) {
|
||||
|
||||
if (items.showIconBadge === undefined) {
|
||||
items.showIconBadge = true;
|
||||
|
@ -123,7 +123,7 @@ options._determineOptionValues = function () {
|
||||
|
||||
let optionKeys = Object.keys(options._optionElements);
|
||||
|
||||
chrome.storage.local.get(optionKeys, function (items) {
|
||||
chrome.storage.sync.get(optionKeys, function (items) {
|
||||
|
||||
options._optionValues = items;
|
||||
resolve();
|
||||
@ -242,7 +242,7 @@ options._onOptionChanged = function ({target}) {
|
||||
optionValue = options._parseDomainWhitelist(optionValue);
|
||||
}
|
||||
|
||||
chrome.storage.local.set({
|
||||
chrome.storage.sync.set({
|
||||
[optionKey]: optionValue
|
||||
});
|
||||
};
|
||||
|
@ -259,7 +259,7 @@ popup._determineAmountInjected = function () {
|
||||
|
||||
return new Promise((resolve) => {
|
||||
|
||||
chrome.storage.local.get(Setting.AMOUNT_INJECTED, function (items) {
|
||||
chrome.storage.sync.get(Setting.AMOUNT_INJECTED, function (items) {
|
||||
|
||||
popup._amountInjected = items.amountInjected || 0;
|
||||
resolve();
|
||||
@ -527,7 +527,7 @@ popup._onMoreInjectionsButton = function () {
|
||||
|
||||
// Store current injections in extension storage.
|
||||
// Maybe a local statistic/diagram will be implemented later.
|
||||
chrome.storage.local.set({
|
||||
chrome.storage.sync.set({
|
||||
[Setting.STATISTIC_DATA]: statisticData
|
||||
});
|
||||
|
||||
|
@ -162,7 +162,7 @@ statistics._createInjectionElement = function (injection) {
|
||||
|
||||
statistics._onDocumentLoaded = function () {
|
||||
|
||||
chrome.storage.local.get([Setting.STATISTIC_DATA], function (items) {
|
||||
chrome.storage.sync.get([Setting.STATISTIC_DATA], function (items) {
|
||||
statisticData = items.statisticData;
|
||||
statistics._renderContents();
|
||||
});
|
||||
|
@ -31,6 +31,7 @@
|
||||
<li>Improved: uMatrix Rule Generator (<a href="https://codeberg.org/nobody/LocalCDN/issues/23">#23</a>)</li>
|
||||
<li>Replaced: Twitter-Bootstrap CSS v2.3.2 with Twitter-Bootstrap CSS Combined v2.3.2</li>
|
||||
<li>Added: D3 Legend v2.25.6</li>
|
||||
<li>Implemented: Sync extension settings with Firefox Sync or own server (experimental)</li>
|
||||
</ul>
|
||||
<div class="topic-label">
|
||||
Please update your uBlock/uMatrix rules
|
||||
|
Loading…
Reference in New Issue
Block a user