From db314ef5205a91ae16efd6af11f62ece67c4bb39 Mon Sep 17 00:00:00 2001 From: Ilya Grigorik Date: Tue, 29 Nov 2016 08:55:19 -0800 Subject: [PATCH 01/11] don't reinitialize active controllers --- inject.js | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/inject.js b/inject.js index 8df5968..9fa64f3 100644 --- a/inject.js +++ b/inject.js @@ -218,15 +218,7 @@ chrome.extension.sendMessage({}, function(response) { function checkForVideo(node, parent, added) { if (node.nodeName === 'VIDEO') { if (added) { - if (!node.classList.contains('vsc-initialized') && !node.dataset['vscid']) { - new tc.videoController(node, parent); - } - // if the video has already been initialized, then it has been mutated - // we may need to update the controller location to reflect this - else { - let id = node.dataset['vscid']; - let ctrl = document.querySelector(`div[data-vscid="${id}"]`); - if (ctrl) ctrl.remove(); + if (!node.dataset['vscid']) { new tc.videoController(node, parent); } } else { From e8f9a1813b015ceba2412d2556540053e13677ec Mon Sep 17 00:00:00 2001 From: Ilya Grigorik Date: Sun, 4 Dec 2016 11:52:45 -0800 Subject: [PATCH 02/11] fix and simplify drag position calculation --- inject.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/inject.js b/inject.js index 9fa64f3..0fa147d 100644 --- a/inject.js +++ b/inject.js @@ -193,7 +193,7 @@ chrome.extension.sendMessage({}, function(response) { // Ignore keydown event if typing in an input box if ((document.activeElement.nodeName === 'INPUT' && document.activeElement.getAttribute('type') === 'text') - || document.activeElement.nodeName === 'TEXTAREA' + || document.activeElement.nodeName === 'TEXTAREA' || document.activeElement.isContentEditable) { return false; } @@ -311,21 +311,15 @@ chrome.extension.sendMessage({}, function(response) { function handleDrag(video, controller) { const parentElement = controller.parentElement, - boundRect = parentElement.getBoundingClientRect(), - shadowController = controller.shadowRoot.querySelector('#controller'), - drag = shadowController.querySelector('.draggable'), - offsetLeft = boundRect.left + drag.offsetLeft + drag.offsetWidth, - offsetTop = boundRect.top + drag.offsetTop + drag.offsetHeight; + shadowController = controller.shadowRoot.querySelector('#controller'); video.classList.add('vcs-dragging'); shadowController.classList.add('dragging'); const startDragging = (e) => { - let newLeft = Math.max(0, e.clientX - offsetLeft); - let newTop = Math.max(0, e.clientY - offsetTop); - - shadowController.style.left = newLeft + 'px'; - shadowController.style.top = newTop + 'px'; + let style = shadowController.style; + style.left = parseInt(style.left) + e.movementX + 'px'; + style.top = parseInt(style.top) + e.movementY + 'px'; } const stopDragging = () => { From ea7b013534d04e4935e63e7c0cb7eb246ed46a37 Mon Sep 17 00:00:00 2001 From: Ilya Grigorik Date: Sun, 4 Dec 2016 12:02:35 -0800 Subject: [PATCH 03/11] move the WebGL controller further down on YT https://github.com/igrigorik/videospeed/issues/134 --- inject.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inject.css b/inject.css index 0a5027f..34e8aef 100644 --- a/inject.css +++ b/inject.css @@ -44,7 +44,7 @@ /* shift YT 3D controller down */ /* e.g. https://www.youtube.com/watch?v=erftYPflJzQ */ .ytp-webgl-spherical-control { - top: 50px !important; + top: 60px !important; } .ytp-fullscreen .ytp-webgl-spherical-control { From 976210a2ebe07bd597952badb725798f3c44d697 Mon Sep 17 00:00:00 2001 From: Ilya Grigorik Date: Sun, 4 Dec 2016 12:06:02 -0800 Subject: [PATCH 04/11] bump to 0.4.3 --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 15afe24..6514834 100755 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "Video Speed Controller", "short_name": "videospeed", - "version": "0.4.2", + "version": "0.4.3", "manifest_version": 2, "description": "Speed up, slow down, advance and rewind any HTML5 video with quick shortcuts.", "homepage_url": "https://github.com/igrigorik/videospeed", From 05790085ff6cc4c7ae784a359b8d2d417ac08f44 Mon Sep 17 00:00:00 2001 From: Ilya Grigorik Date: Tue, 6 Dec 2016 19:30:09 -0800 Subject: [PATCH 05/11] clear dataset ID when removing controller closes #155. --- inject.js | 1 + 1 file changed, 1 insertion(+) diff --git a/inject.js b/inject.js index 0fa147d..92c740b 100644 --- a/inject.js +++ b/inject.js @@ -227,6 +227,7 @@ chrome.extension.sendMessage({}, function(response) { let ctrl = document.querySelector(`div[data-vscid="${id}"]`) if (ctrl) { node.classList.remove('vsc-initialized'); + delete node.dataset['vscid']; ctrl.remove(); } } From 8300c3a8e9a4a0c90018ee1d954b35e0215b9ddf Mon Sep 17 00:00:00 2001 From: Ilya Grigorik Date: Wed, 7 Dec 2016 14:25:18 -0800 Subject: [PATCH 06/11] bump to 0.4.4 --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 6514834..7c38df7 100755 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "Video Speed Controller", "short_name": "videospeed", - "version": "0.4.3", + "version": "0.4.4", "manifest_version": 2, "description": "Speed up, slow down, advance and rewind any HTML5 video with quick shortcuts.", "homepage_url": "https://github.com/igrigorik/videospeed", From 4a3d170f84d25ea32a59a09e04bc3a8f36f108fa Mon Sep 17 00:00:00 2001 From: Ilya Grigorik Date: Thu, 22 Dec 2016 17:12:51 -0800 Subject: [PATCH 07/11] new option to hide controller by default When enabled controller visibility in 'manual' mode: to hide/unhide the user needs to use the configured shortcut keys. Closes https://github.com/igrigorik/videospeed/issues/156. --- inject.js | 6 ++++++ options.html | 4 ++++ options.js | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/inject.js b/inject.js index 92c740b..5adf45c 100644 --- a/inject.js +++ b/inject.js @@ -12,6 +12,7 @@ chrome.extension.sendMessage({}, function(response) { advanceKeyCode: 88, // default: X displayKeyCode: 86, // default: V rememberSpeed: false, // default: false + startHidden: false, // default: false blacklist: ` www.instagram.com twitter.com @@ -33,6 +34,7 @@ chrome.extension.sendMessage({}, function(response) { tc.settings.displayKeyCode = Number(storage.displayKeyCode); tc.settings.advanceKeyCode = Number(storage.advanceKeyCode); tc.settings.rememberSpeed = Boolean(storage.rememberSpeed); + tc.settings.startHidden = Boolean(storage.startHidden); tc.settings.blacklist = String(storage.blacklist); initializeWhenReady(document); @@ -94,6 +96,10 @@ chrome.extension.sendMessage({}, function(response) { wrapper.addEventListener('mousedown', prevent, true); wrapper.addEventListener('click', prevent, true); + if (tc.settings.startHidden) { + wrapper.classList.add('vsc-hidden'); + } + var shadow = wrapper.createShadowRoot(); var shadowTemplate = `