mirror of
https://github.com/SoPat712/videospeed.git
synced 2025-08-22 02:18:45 -04:00
fixes #332 this adds keydown listener to parent document if there is one. it does not use background files which uses unnecessary ram
This commit is contained in:

committed by
Ilya Grigorik

parent
0999acc7fc
commit
e84e19069d
15
inject.js
15
inject.js
@@ -203,7 +203,13 @@ chrome.runtime.sendMessage({}, function(response) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
inIframe () {
|
||||||
|
try {
|
||||||
|
return window.self !== window.top;
|
||||||
|
} catch (e) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
function initializeNow(document) {
|
function initializeNow(document) {
|
||||||
// enforce init-once due to redundant callers
|
// enforce init-once due to redundant callers
|
||||||
if (!document.body || document.body.classList.contains('vsc-initialized')) {
|
if (!document.body || document.body.classList.contains('vsc-initialized')) {
|
||||||
@@ -220,8 +226,12 @@ chrome.runtime.sendMessage({}, function(response) {
|
|||||||
link.rel = 'stylesheet';
|
link.rel = 'stylesheet';
|
||||||
document.head.appendChild(link);
|
document.head.appendChild(link);
|
||||||
}
|
}
|
||||||
|
var docs = Array(document)
|
||||||
|
if(inIframe())
|
||||||
|
docs.push(window.top.document);
|
||||||
|
|
||||||
document.addEventListener('keydown', function(event) {
|
docs.forEach(function(doc) {
|
||||||
|
doc.addEventListener('keydown', function(event) {
|
||||||
var keyCode = event.keyCode;
|
var keyCode = event.keyCode;
|
||||||
|
|
||||||
// Ignore if following modifier is active.
|
// Ignore if following modifier is active.
|
||||||
@@ -261,6 +271,7 @@ chrome.runtime.sendMessage({}, function(response) {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}, true);
|
}, true);
|
||||||
|
});
|
||||||
|
|
||||||
function checkForVideo(node, parent, added) {
|
function checkForVideo(node, parent, added) {
|
||||||
if (node.nodeName === 'VIDEO') {
|
if (node.nodeName === 'VIDEO') {
|
||||||
|
Reference in New Issue
Block a user