#19 Added loading bar observer

This commit is contained in:
Serraniel 2020-10-25 10:54:32 +01:00
parent 8a2f1d90b2
commit 585c1684a2
Signed by: Serraniel
GPG key ID: 3690B4E7364525D3

View file

@ -20,8 +20,31 @@ export function initCore() {
attributes: true
});
patchBrowser();
window.addEventListener('locationchange', (event) => handleLocationChanged(event));
// patchBrowser();
// window.addEventListener('locationchange', (event) => handleLocationChanged(event));
runAfterLoad(() => {
let loadingBar = document.getElementById('enable-ani-cm');
let loadingBarObserver = new MutationObserver(mutations => {
mutations.forEach(mutation => {
// enable-ani-cm node changes from display:none to display:block after loading
if (mutation.oldValue.includes('display: none')) {
__afterPathnameChangeScripts.forEach(script => {
if (window.location.pathname.match(script.pattern)) {
script.function();
}
});
}
})
});
loadingBarObserver.observe(loadingBar, {
attributes: true,
attributeOldValue: true,
attributeFilter: ['style'],
});
}, '.*')
helper.onReady(() => awaitPageLoaded());
}