2017-10-12 19:00:04 +00:00
|
|
|
(function () {
|
|
|
|
"use strict";
|
|
|
|
|
2017-10-13 22:30:57 +00:00
|
|
|
const rootObject = (window.browser || window.chrome);
|
2017-10-12 19:00:04 +00:00
|
|
|
const doc = window.document;
|
|
|
|
const standards = window.WEB_API_MANAGER.standards;
|
|
|
|
const {storageLib, stateLib} = window.WEB_API_MANAGER;
|
|
|
|
const defaultDomain = "(default)";
|
2017-10-23 05:17:23 +00:00
|
|
|
const Vue = window.Vue;
|
2017-10-12 19:00:04 +00:00
|
|
|
|
|
|
|
const state = stateLib.generateStateObject(defaultDomain, standards);
|
|
|
|
|
2017-10-15 04:23:40 +00:00
|
|
|
const onSettingsLoaded = function (storedSettings) {
|
2017-10-12 19:00:04 +00:00
|
|
|
|
2017-10-15 04:23:40 +00:00
|
|
|
state.populateFromStorage(storedSettings);
|
2017-10-14 20:24:18 +00:00
|
|
|
|
2017-10-12 19:00:04 +00:00
|
|
|
const vm = new Vue({
|
|
|
|
el: doc.body,
|
|
|
|
data: state
|
|
|
|
});
|
|
|
|
|
|
|
|
const updateStoredSettings = function () {
|
2017-10-15 04:23:40 +00:00
|
|
|
storageLib.set(state.toStorage(), function () {
|
|
|
|
rootObject.runtime.sendMessage(["stateUpdate", state.toStorage()]);
|
2017-10-13 22:30:57 +00:00
|
|
|
});
|
2017-10-12 19:00:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
vm.$watch("selectedStandards", updateStoredSettings);
|
|
|
|
vm.$watch("domainNames", updateStoredSettings);
|
2017-10-15 04:23:40 +00:00
|
|
|
vm.$watch("shouldLog", updateStoredSettings);
|
2017-10-12 19:00:04 +00:00
|
|
|
};
|
|
|
|
|
2017-10-15 04:23:40 +00:00
|
|
|
window.onload = function () {
|
2017-10-12 19:00:04 +00:00
|
|
|
storageLib.get(onSettingsLoaded);
|
|
|
|
};
|
2017-10-23 08:29:59 +00:00
|
|
|
}());
|