* Start observing the changes in the DOM
()
| 251 | * Start observing the changes in the DOM |
| 252 | */ |
| 253 | function startDOMObserver() { |
| 254 | |
| 255 | if (isObserverActive) { |
| 256 | console.warn("Tried starting the observer, but it was already running."); |
| 257 | return; |
| 258 | } |
| 259 | |
| 260 | // Observer all the changes of the DOM elements position and attribute for the body tag and its children |
| 261 | const targetNode = document.body; |
| 262 | const config = { attributes: true, childList: true, subtree: true }; |
| 263 | |
| 264 | observer.observe(targetNode, config); |
| 265 | isObserverActive = true; |
| 266 | |
| 267 | // Disconnect the observer when the user is leaving the page |
| 268 | window.addEventListener("beforeunload", disconnectObserver); |
| 269 | } |
| 270 | |
| 271 | |
| 272 | /** |
nothing calls this directly
no outgoing calls
no test coverage detected