Add extra checks for document.body

This commit is contained in:
varjolintu 2020-10-15 22:12:34 +03:00
parent 6cff401638
commit 7b14bed64e
2 changed files with 10 additions and 4 deletions

View file

@ -1588,7 +1588,8 @@ kpxcObserverHelper.ignoredElement = function(target) {
// Ignores all nodes that doesn't contain elements
// Also ignore few Youtube-specific custom nodeNames
kpxcObserverHelper.ignoredNode = function(target) {
if (kpxcObserverHelper.ignoredNodeTypes.some(e => e === target.nodeType)
if (!target
||kpxcObserverHelper.ignoredNodeTypes.some(e => e === target.nodeType)
|| kpxcObserverHelper.ignoredNodeNames.some(e => e === target.nodeName)
|| target.nodeName.startsWith('YTMUSIC')
|| target.nodeName.startsWith('YT-')) {
@ -1647,7 +1648,9 @@ kpxcObserverHelper.initObserver = async function() {
}
});
kpxc.observer.observe(document.body, kpxcObserverHelper.observerConfig);
if (document.body) {
kpxc.observer.observe(document.body, kpxcObserverHelper.observerConfig);
}
};
MutationObserver = window.MutationObserver || window.WebKitMutationObserver;

View file

@ -55,10 +55,13 @@ class Icon {
}
const kpxcUI = {};
kpxcUI.bodyRect = document.body.getBoundingClientRect();
kpxcUI.bodyStyle = getComputedStyle(document.body);
kpxcUI.mouseDown = false;
if (document.body) {
kpxcUI.bodyRect = document.body.getBoundingClientRect();
kpxcUI.bodyStyle = getComputedStyle(document.body);
}
// Wrapper for creating elements
kpxcUI.createElement = function(type, classes, attributes, textContent) {
const element = document.createElement(type);