Waiting for head to load before inserting banner

pull/227/head
Kevin Payravi 2023-07-17 00:17:50 -05:00
parent aaefcbd468
commit 221b18621c
1 changed files with 17 additions and 7 deletions

View File

@ -394,8 +394,18 @@ function main(mutations = null, observer = null) {
} else { } else {
newURL = 'https://' + site["destination_base_url"]; newURL = 'https://' + site["destination_base_url"];
} }
// Notify that another wiki is available // When head elem is loaded, notify that another wiki is available
const docObserver = new MutationObserver(function (mutations, mutationInstance) {
const headElement = document.querySelector('head');
if (headElement) {
displayRedirectBanner(newURL, site['id'], site['destination'], storage); displayRedirectBanner(newURL, site['id'], site['destination'], storage);
mutationInstance.disconnect();
}
});
docObserver.observe(document, {
childList: true,
subtree: true
});
} }
} }
} }