diff --git a/keepassxc-browser/content/ui.js b/keepassxc-browser/content/ui.js index e3a6d4a..1a77d3c 100644 --- a/keepassxc-browser/content/ui.js +++ b/keepassxc-browser/content/ui.js @@ -431,8 +431,12 @@ kpxcUI.createPageObserver = function() { } }); - kpxcUI.pageObserver.observe(document.documentElement, OBSERVER_OPTIONS); - kpxcUI.pageObserver.observe(document.body, OBSERVER_OPTIONS); + if (document?.documentElement) { + kpxcUI.pageObserver.observe(document.documentElement, OBSERVER_OPTIONS); + } + if (document?.body) { + kpxcUI.pageObserver.observe(document.body, OBSERVER_OPTIONS); + } }; const DOMRectToArray = function(domRect) {