diff --git a/core/interceptor.js b/core/interceptor.js index 0f07aad9..8b394e97 100644 --- a/core/interceptor.js +++ b/core/interceptor.js @@ -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; diff --git a/core/state-manager.js b/core/state-manager.js index e9161582..64161b03 100644 --- a/core/state-manager.js +++ b/core/state-manager.js @@ -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) { diff --git a/core/storage-manager.js b/core/storage-manager.js index 33313b2b..2b85a759 100644 --- a/core/storage-manager.js +++ b/core/storage-manager.js @@ -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); diff --git a/modules/internal/stats.js b/modules/internal/stats.js index 48100212..406df230 100644 --- a/modules/internal/stats.js +++ b/modules/internal/stats.js @@ -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 = {};