fix: update sitewide.js loading order using PageLoad()

This commit is contained in:
Index 2024-07-01 04:06:46 -05:00
parent 14250d1add
commit 8c249ad624

View file

@ -45,35 +45,6 @@ let Theme = ``;
} }
} }
} }
}
if (document.readyState === 'complete') {
PageLoad()
} else {
document.addEventListener('DOMContentLoaded', PageLoad);
}
// Apply Theme
LoadTheme();
const combination = "reload";
let currentCombination = "";
document.addEventListener("keypress", function (e) {
currentCombination += e.key;
if (currentCombination === combination && document.activeElement.tagName !== "INPUT" && document.activeElement.tagName !== "TEXTAREA") {
try {
console.log("Reloading Poly+...");
chrome.runtime.sendMessage({ action: "reload" });
window.location.reload();
} catch(error) {
console.log("Reloading Poly+...");
window.location.reload()
chrome.runtime.sendMessage({ action: "reload" });
window.location.reload();
}
} else if (!combination.startsWith(currentCombination)) {
currentCombination = "";
}
});
if (Settings.HideUserAds && Settings.HideUserAds.Enabled === true) { if (Settings.HideUserAds && Settings.HideUserAds.Enabled === true) {
if (Settings.HideUserAds.Banners && Settings.HideUserAds.Banners === true) { if (Settings.HideUserAds.Banners && Settings.HideUserAds.Banners === true) {
@ -114,6 +85,35 @@ let Theme = ``;
const ThemeBlob = new Blob([Theme], { type: 'text/css' }); const ThemeBlob = new Blob([Theme], { type: 'text/css' });
const ThemeURL = URL.createObjectURL(ThemeBlob); const ThemeURL = URL.createObjectURL(ThemeBlob);
document.head.innerHTML += `<link href="${ThemeURL}" rel="stylesheet" type="text/css">`; document.head.innerHTML += `<link href="${ThemeURL}" rel="stylesheet" type="text/css">`;
}
if (document.readyState === 'complete') {
PageLoad()
} else {
document.addEventListener('DOMContentLoaded', PageLoad);
}
// Apply Theme
LoadTheme();
const combination = "reload";
let currentCombination = "";
document.addEventListener("keypress", function (e) {
currentCombination += e.key;
if (currentCombination === combination && document.activeElement.tagName !== "INPUT" && document.activeElement.tagName !== "TEXTAREA") {
try {
console.log("Reloading Poly+...");
chrome.runtime.sendMessage({ action: "reload" });
window.location.reload();
} catch(error) {
console.log("Reloading Poly+...");
window.location.reload()
chrome.runtime.sendMessage({ action: "reload" });
window.location.reload();
}
} else if (!combination.startsWith(currentCombination)) {
currentCombination = "";
}
});
}); });
})(); })();