mirror of
https://github.com/SoPat712/videospeed.git
synced 2025-08-21 18:08:46 -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) {
|
||||
// enforce init-once due to redundant callers
|
||||
if (!document.body || document.body.classList.contains('vsc-initialized')) {
|
||||
@@ -220,8 +226,12 @@ chrome.runtime.sendMessage({}, function(response) {
|
||||
link.rel = 'stylesheet';
|
||||
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;
|
||||
|
||||
// Ignore if following modifier is active.
|
||||
@@ -261,6 +271,7 @@ chrome.runtime.sendMessage({}, function(response) {
|
||||
|
||||
return false;
|
||||
}, true);
|
||||
});
|
||||
|
||||
function checkForVideo(node, parent, added) {
|
||||
if (node.nodeName === 'VIDEO') {
|
||||
|
Reference in New Issue
Block a user