fix: theme settings being applied before settings
fixes `TypeError: Settings is undefined` on firefox
This commit is contained in:
parent
35bc026724
commit
456bf389f0
3 changed files with 191 additions and 183 deletions
|
|
@ -4,6 +4,7 @@ var Settings;
|
||||||
let Utilities;
|
let Utilities;
|
||||||
|
|
||||||
chrome.storage.sync.get(['PolyPlus_Settings'], function (result) {
|
chrome.storage.sync.get(['PolyPlus_Settings'], function (result) {
|
||||||
|
console.log(result);
|
||||||
Settings = result.PolyPlus_Settings;
|
Settings = result.PolyPlus_Settings;
|
||||||
|
|
||||||
if (Settings.IRLPriceWithCurrency && Settings.IRLPriceWithCurrency.Enabled === true) {
|
if (Settings.IRLPriceWithCurrency && Settings.IRLPriceWithCurrency.Enabled === true) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
const SettingsURL = chrome.runtime.getURL('settings.html');
|
const SettingsURL = chrome.runtime.getURL('settings.html');
|
||||||
const InExtensionSettings = window.location.pathname.split('/')[3] === 'polyplus' && window.location.hash !== '#dev' && window.location.hash !== '#debug';
|
const InExtensionSettings = window.location.pathname.split('/')[3] === 'polyplus' && window.location.hash !== '#dev' && window.location.hash !== '#debug';
|
||||||
|
|
||||||
if (InExtensionSettings === true) {
|
if (InExtensionSettings === true) {
|
||||||
window.location.href = SettingsURL + window.location.hash;
|
window.location.href = SettingsURL + window.location.hash;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
var Settings;
|
var Settings;
|
||||||
let Theme = ``;
|
let Theme = ``;
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
let Utilities = await import(chrome.runtime.getURL('resources/utils.js'));
|
let Utilities = await import(chrome.runtime.getURL('resources/utils.js'));
|
||||||
Utilities = Utilities.default;
|
Utilities = Utilities.default;
|
||||||
|
|
@ -9,6 +10,12 @@ let Theme = ``;
|
||||||
const RawSettings = result.PolyPlus_Settings;
|
const RawSettings = result.PolyPlus_Settings;
|
||||||
Settings = MergeObjects(RawSettings || Utilities.DefaultSettings, Utilities.DefaultSettings);
|
Settings = MergeObjects(RawSettings || Utilities.DefaultSettings, Utilities.DefaultSettings);
|
||||||
|
|
||||||
|
// Apply theme settings after Settings is defined
|
||||||
|
applyThemeSettings();
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
|
||||||
|
function applyThemeSettings() {
|
||||||
// If theme exists, create a style element to represent it
|
// If theme exists, create a style element to represent it
|
||||||
if (Settings.ThemeCreator && Settings.ThemeCreator.Enabled === true) {
|
if (Settings.ThemeCreator && Settings.ThemeCreator.Enabled === true) {
|
||||||
switch (Settings.ThemeCreator.BGImageSize) {
|
switch (Settings.ThemeCreator.BGImageSize) {
|
||||||
|
|
@ -110,7 +117,6 @@ let Theme = ``;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
const combination = "reload";
|
const combination = "reload";
|
||||||
|
|
@ -201,7 +207,7 @@ let Theme = ``;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})();
|
}
|
||||||
|
|
||||||
function MergeObjects(obj1, obj2) {
|
function MergeObjects(obj1, obj2) {
|
||||||
var mergedObj = {};
|
var mergedObj = {};
|
||||||
|
|
|
||||||
Reference in a new issue