From 1342d5bb060ab4bd6223de3accfd000068e251c8 Mon Sep 17 00:00:00 2001 From: Ilya Grigorik Date: Thu, 9 Jun 2016 22:55:39 -0400 Subject: [PATCH] YT fix: show on keyboard input --- inject.css | 5 +++++ inject.js | 30 ++++++++++++------------------ 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/inject.css b/inject.css index 7013b31..e80c15e 100644 --- a/inject.css +++ b/inject.css @@ -11,6 +11,11 @@ opacity: 0; } +.ytp-autohide .vcs-show { + visibility: visible; + opacity: 1.0; +} + /* YouTube embedded player */ /* e.g. https://www.igvita.com/2012/09/12/web-fonts-performance-making-pretty-fast/ */ .full-frame .html5-video-player:not(.ytp-fullscreen) .vsc-controller { diff --git a/inject.js b/inject.js index b6f2486..372d673 100644 --- a/inject.js +++ b/inject.js @@ -15,7 +15,6 @@ chrome.extension.sendMessage({}, function(response) { } }; - var controllerAnimation; chrome.storage.sync.get(tc.settings, function(storage) { tc.settings.speed = Number(storage.speed); tc.settings.speedStep = Number(storage.speedStep); @@ -209,8 +208,7 @@ chrome.extension.sendMessage({}, function(response) { videoTags.forEach(function(v) { var id = v.dataset['vscid']; - var controller = document.querySelector(`div[data-vscid="${id}"]`) - .shadowRoot.querySelector('#controller'); + var controller = document.querySelector(`div[data-vscid="${id}"]`); if (keyboard) showController(controller); @@ -240,23 +238,19 @@ chrome.extension.sendMessage({}, function(response) { }); } + var timer; + var animation = false; function showController(controller) { - controller.style.visibility = 'visible'; - if (controllerAnimation != null - && controllerAnimation.playState != 'finished') { - controllerAnimation.cancel(); - } + controller.classList.add('vcs-show'); - // TODO : if controller is visible, do not start animation. - controllerAnimation = controller.animate([ - {opacity: 0.3}, - {opacity: 0.3}, - {opacity: 0.0}, - ], { - duration: 2000, - iterations: 1, - delay: 0 - }); + if (animation) + clearTimeout(timer); + + animation = true; + timer = setTimeout(function() { + controller.classList.remove('vcs-show'); + animation = false; + }, 2000); } initializeWhenReady(document);