2020-02-27 13:45:29 +01:00
|
|
|
/**
|
|
|
|
* Entry Point
|
2020-06-30 18:41:58 +02:00
|
|
|
* Belongs to LocalCDN (since 2020-02-26)
|
|
|
|
* (Origin: Decentraleyes)
|
2020-02-27 13:45:29 +01:00
|
|
|
*
|
|
|
|
* @author Thomas Rientjes
|
|
|
|
* @since 2016-04-04
|
2020-06-30 18:41:58 +02:00
|
|
|
*
|
|
|
|
* @author nobody
|
|
|
|
* @since 2020-02-26
|
|
|
|
*
|
2020-02-27 13:45:29 +01:00
|
|
|
* @license MPL-2.0
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*/
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Main
|
|
|
|
*/
|
|
|
|
|
|
|
|
var main = {};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Private Methods
|
|
|
|
*/
|
|
|
|
|
|
|
|
main._initializeSettings = function () {
|
2020-08-30 18:56:36 +02:00
|
|
|
storageManager.checkStorageType();
|
|
|
|
|
|
|
|
storageManager.type.get(SettingDefaults, function (items) {
|
2020-02-27 13:45:29 +01:00
|
|
|
if (items === null) {
|
2020-08-30 18:35:08 +02:00
|
|
|
items = SettingDefaults; // Restore setting defaults.
|
2020-02-27 13:45:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (items.disablePrefetch !== false) {
|
|
|
|
chrome.privacy.network.networkPredictionEnabled.set({
|
|
|
|
'value': false
|
|
|
|
});
|
|
|
|
}
|
2020-07-09 20:58:18 +02:00
|
|
|
stateManager.selectedIcon = items.selectedIcon;
|
2020-07-08 16:37:03 +02:00
|
|
|
wrappers.setIcon({
|
2020-07-09 20:58:18 +02:00
|
|
|
'path': stateManager.selectedIcon
|
|
|
|
}, 'Enabled');
|
2020-02-27 13:45:29 +01:00
|
|
|
|
2020-08-30 18:56:36 +02:00
|
|
|
storageManager.type.set(items);
|
2020-02-27 13:45:29 +01:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
main._showReleaseNotes = function (details) {
|
2020-08-30 18:56:36 +02:00
|
|
|
storageManager.checkStorageType();
|
|
|
|
|
2020-03-08 12:30:03 +01:00
|
|
|
if (details.reason === chrome.runtime.OnInstalledReason.INSTALL) {
|
2020-08-30 18:56:36 +02:00
|
|
|
storageManager.type.set({
|
2020-04-06 18:04:53 +02:00
|
|
|
[Setting.LAST_MAPPING_UPDATE]: lastMappingUpdate
|
|
|
|
}, function() {
|
|
|
|
if (details.temporary !== true) {
|
2020-02-27 13:45:29 +01:00
|
|
|
|
2020-08-30 18:56:36 +02:00
|
|
|
storageManager.type.get([Setting.HIDE_RELEASE_NOTES], function (items) {
|
2020-02-27 13:45:29 +01:00
|
|
|
|
2020-04-06 18:04:53 +02:00
|
|
|
if (items.hideReleaseNotes !== true) {
|
|
|
|
|
|
|
|
chrome.tabs.create({
|
2020-07-14 17:54:25 +02:00
|
|
|
'url': chrome.extension.getURL('pages/welcome/welcome.html'),
|
2020-04-06 18:04:53 +02:00
|
|
|
'active': false
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2020-03-08 12:30:03 +01:00
|
|
|
} else if (details.reason === chrome.runtime.OnInstalledReason.UPDATE) {
|
2020-08-30 18:56:36 +02:00
|
|
|
storageManager.type.get([Setting.LAST_MAPPING_UPDATE, Setting.HIDE_RELEASE_NOTES], function (items) {
|
2020-07-24 08:16:25 +02:00
|
|
|
let mappingUpdate = items.lastMappingUpdate !== lastMappingUpdate;
|
2020-04-06 18:04:53 +02:00
|
|
|
|
2020-07-24 08:16:25 +02:00
|
|
|
if (mappingUpdate || !items.hideReleaseNotes) {
|
2020-03-08 12:30:03 +01:00
|
|
|
// Updated mappings.js
|
2020-08-30 18:56:36 +02:00
|
|
|
storageManager.type.set({
|
2020-07-24 08:16:25 +02:00
|
|
|
[Setting.LAST_MAPPING_UPDATE]: lastMappingUpdate
|
2020-04-06 18:04:53 +02:00
|
|
|
}, function() {
|
2020-09-12 17:22:25 +02:00
|
|
|
if (!items.hideReleaseNotes) {
|
2020-09-19 08:01:31 +02:00
|
|
|
chrome.tabs.create({
|
|
|
|
'url': chrome.extension.getURL('pages/updates/updates.html?mappingupdate=' + mappingUpdate),
|
|
|
|
'active': false
|
|
|
|
});
|
2020-04-06 18:04:53 +02:00
|
|
|
}
|
2020-03-08 12:30:03 +01:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
// No mappings.js update
|
2020-04-06 18:04:53 +02:00
|
|
|
return;
|
2020-03-08 12:30:03 +01:00
|
|
|
}
|
|
|
|
});
|
2020-02-27 13:45:29 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initializations
|
|
|
|
*/
|
|
|
|
chrome.runtime.onInstalled.addListener(main._showReleaseNotes);
|
|
|
|
main._initializeSettings();
|