move controller check into initialization

This commit is contained in:
Ilya Grigorik
2017-07-03 09:17:51 +02:00
parent 212616da72
commit 18455d521f

View File

@@ -50,6 +50,10 @@ chrome.extension.sendMessage({}, function(response) {
function defineVideoController() { function defineVideoController() {
tc.videoController = function(target, parent) { tc.videoController = function(target, parent) {
if (target.dataset['vscid']) {
return;
}
this.video = target; this.video = target;
this.parent = target.parentElement || parent; this.parent = target.parentElement || parent;
this.document = target.ownerDocument; this.document = target.ownerDocument;
@@ -244,9 +248,7 @@ chrome.extension.sendMessage({}, function(response) {
function checkForVideo(node, parent, added) { function checkForVideo(node, parent, added) {
if (node.nodeName === 'VIDEO') { if (node.nodeName === 'VIDEO') {
if (added) { if (added) {
if (!node.dataset['vscid']) { new tc.videoController(node, parent);
new tc.videoController(node, parent);
}
} else { } else {
if (node.classList.contains('vsc-initialized')) { if (node.classList.contains('vsc-initialized')) {
let id = node.dataset['vscid']; let id = node.dataset['vscid'];