Availability of certain variables changed (#92)

This commit is contained in:
nobody 2020-09-08 20:50:54 +02:00
parent e2536dff2e
commit 34fba9c79d
No known key found for this signature in database
GPG Key ID: 8F6DE3D614FCFD7A
4 changed files with 16 additions and 10 deletions

View File

@ -126,7 +126,6 @@ interceptor._handleStorageChanged = function (changes) {
* Initializations
*/
interceptor.amountInjected = 0;
interceptor.xhrTestDomain = Address.LOCALCDN;
interceptor.blockMissing = false;
interceptor.blockGoogleFonts = true;
@ -140,7 +139,7 @@ interceptor.relatedSettings.push(Setting.BLOCK_MISSING);
interceptor.relatedSettings.push(Setting.ALLOWED_DOMAINS_GOOGLE_FONTS);
storageManager.type.get(interceptor.relatedSettings, function (items) {
interceptor.amountInjected = items.amountInjected || 0;
storageManager.amountInjected = items.amountInjected || 0;
interceptor.xhrTestDomain = items.xhrTestDomain || Address.LOCALCDN;
interceptor.blockMissing = items.blockMissing || false;
interceptor.blockGoogleFonts = items.blockGoogleFonts || true;

View File

@ -54,21 +54,21 @@ stateManager.registerInjection = function (tabIdentifier, injection) {
}
}
if (isNaN(interceptor.amountInjected)) {
if (isNaN(storageManager.amountInjected)) {
storageManager.type.get(Setting.AMOUNT_INJECTED, function (items) {
interceptor.amountInjected = items.amountInjected;
storageManager.amountInjected = items.amountInjected;
storageManager.type.set({
[Setting.AMOUNT_INJECTED]: ++interceptor.amountInjected
[Setting.AMOUNT_INJECTED]: ++storageManager.amountInjected
});
});
} else {
chrome.storage.local.set({
[Setting.AMOUNT_INJECTED]: ++interceptor.amountInjected
[Setting.AMOUNT_INJECTED]: ++storageManager.amountInjected
});
}
if (stateManager.internalStatistics) {

View File

@ -152,7 +152,14 @@ storageManager._validation = function (content) {
throw 'Invalid file!';
}
}
// set values directly
wrappers.setIcon({ path: imported['selectedIcon'] }, 'Enabled');
storageManager.amountInjected = imported['amountInjected'];
storageManager.statistics = imported['internalStatisticsData'];
storageManager.type.set(imported);
alert(chrome.i18n.getMessage('dialogImportSuccessful'));
};
@ -232,5 +239,7 @@ storageManager._validateNumbers = function (value) {
storageManager.data = {};
storageManager.type = chrome.storage.local;
storageManager.amountInjected = 0;
storageManager.statistics = {};
chrome.storage.onChanged.addListener(storageManager._handleStorageChanged);

View File

@ -23,7 +23,7 @@ var stats = {};
stats.setStats = function (injection) {
let data, today, cdn, framework, newEntry;
data = stats.data;
data = storageManager.statistics;
today = new Date().toISOString().slice(0, 10);
cdn = injection.source;
framework = injection.path;
@ -51,10 +51,8 @@ stats.setStats = function (injection) {
stats.getStats = function () {
chrome.storage.local.get([Setting.INTERNAL_STATISTICS_DATA], function (items) {
stats.data = items.internalStatisticsData || {};
storageManager.statistics = items.internalStatisticsData || {};
});
};
stats.getStats();
stats.data = {};