Merge pull request #9 from okdargy/main

fix settings being undefined on change load
This commit is contained in:
Index 2024-06-18 00:11:57 -05:00 committed by GitHub
commit c0dbbdeb0d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 190 additions and 183 deletions

View file

@ -1,5 +1,6 @@
const SettingsURL = chrome.runtime.getURL('settings.html');
const InExtensionSettings = window.location.pathname.split('/')[3] === 'polyplus' && window.location.hash !== '#dev' && window.location.hash !== '#debug';
if (InExtensionSettings === true) {
window.location.href = SettingsURL + window.location.hash;
}

View file

@ -1,5 +1,6 @@
var Settings;
let Theme = ``;
(async () => {
let Utilities = await import(chrome.runtime.getURL('resources/utils.js'));
Utilities = Utilities.default;
@ -9,6 +10,12 @@ let Theme = ``;
const RawSettings = result.PolyPlus_Settings;
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 (Settings.ThemeCreator && Settings.ThemeCreator.Enabled === true) {
switch (Settings.ThemeCreator.BGImageSize) {
@ -110,7 +117,6 @@ let Theme = ``;
}
`;
}
});
const combination = "reload";
let currentCombination = "";
@ -200,7 +206,7 @@ let Theme = ``;
});
}
});
})();
}
function MergeObjects(obj1, obj2) {
var mergedObj = {};