mirror of
https://github.com/SoPat712/videospeed.git
synced 2025-08-22 02:18:45 -04:00
20
inject.js
20
inject.js
@@ -166,15 +166,23 @@ chrome.extension.sendMessage({}, function(response) {
|
|||||||
return false;
|
return false;
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
function checkForVideo(node, parent) {
|
function checkForVideo(node, parent, added) {
|
||||||
if (node.nodeName === 'VIDEO') {
|
if (node.nodeName === 'VIDEO') {
|
||||||
|
if (added) {
|
||||||
if (!node.classList.contains('vsc-initialized')) {
|
if (!node.classList.contains('vsc-initialized')) {
|
||||||
new tc.videoController(node, parent);
|
new tc.videoController(node, parent);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (node.classList.contains('vsc-initialized')) {
|
||||||
|
var id = node.dataset['vscid'];
|
||||||
|
document.querySelector(`div[data-vscid="${id}"]`).remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (node.children != undefined) {
|
} else if (node.children != undefined) {
|
||||||
for (var i = 0; i < node.children.length; i++) {
|
for (var i = 0; i < node.children.length; i++) {
|
||||||
checkForVideo(node.children[i],
|
checkForVideo(node.children[i],
|
||||||
node.children[i].parentNode || parent);
|
node.children[i].parentNode || parent,
|
||||||
|
added);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -183,8 +191,12 @@ chrome.extension.sendMessage({}, function(response) {
|
|||||||
forEach.call(mutation.addedNodes, function(node) {
|
forEach.call(mutation.addedNodes, function(node) {
|
||||||
if (typeof node === "function")
|
if (typeof node === "function")
|
||||||
return;
|
return;
|
||||||
|
checkForVideo(node, node.parentNode || mutation.target, true);
|
||||||
checkForVideo(node, node.parentNode || mutation.target);
|
})
|
||||||
|
forEach.call(mutation.removedNodes, function(node) {
|
||||||
|
if (typeof node === "function")
|
||||||
|
return;
|
||||||
|
checkForVideo(node, node.parentNode || mutation.target, false);
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user