Commit a3f400c8 authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇
Browse files

Install MutationObserver in DOMContentLoaded

They are mostly meant to detect when a player is dynamically added/removed by AJAX when e.g.
an overlay opens.
I don't think it's necessary to monitor the page being constructed, potentially slowing it down.
Especially since in DOMContentLoaded we will register all players anyway.
parent ccd47495
...@@ -603,11 +603,6 @@ function loadMpris() { ...@@ -603,11 +603,6 @@ function loadMpris() {
}); });
}); });
observer.observe(document, {
childList: true,
subtree: true
});
window.addEventListener("pagehide", function () { window.addEventListener("pagehide", function () {
// about to navigate to a different page, tell our extension that the player will be gone shortly // about to navigate to a different page, tell our extension that the player will be gone shortly
// we listen for tab closed in the extension but we don't for navigating away as URL change doesn't // we listen for tab closed in the extension but we don't for navigating away as URL change doesn't
...@@ -622,6 +617,11 @@ function loadMpris() { ...@@ -622,6 +617,11 @@ function loadMpris() {
document.addEventListener("DOMContentLoaded", function() { document.addEventListener("DOMContentLoaded", function() {
registerAllPlayers(); registerAllPlayers();
observer.observe(document, {
childList: true,
subtree: true
});
}); });
document.addEventListener("fullscreenchange", () => { document.addEventListener("fullscreenchange", () => {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment