diff --git a/_locales/en/messages.json b/_locales/en/messages.json index b37e59825..ce44d89c3 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -131,6 +131,7 @@ "device":{"message":"Device"}, "dim":{"message":"Dim"}, "disabled":{"message":"Disabled"}, +"disableThumbnailPlayback":{"message":"Disable video playback on hover"}, "dislike":{"message":"Dislike"}, "displayDayOfTheWeak":{"message":"Display day of the week"}, "doNotChange":{"message":"Don't change"}, diff --git a/js&css/extension/init.js b/js&css/extension/init.js index feabe4242..bd08ec575 100644 --- a/js&css/extension/init.js +++ b/js&css/extension/init.js @@ -39,6 +39,7 @@ extension.events.on('init', function () { extension.features.confirmationBeforeClosing(); extension.features.defaultContentCountry(); extension.features.popupWindowButtons(); + extension.features.disableThumbnailPlayback(); extension.features.markWatchedVideos(); extension.features.relatedVideos(); extension.features.comments(); diff --git a/js&css/extension/www.youtube.com/general/general.js b/js&css/extension/www.youtube.com/general/general.js index 79f859fba..266a68d0e 100644 --- a/js&css/extension/www.youtube.com/general/general.js +++ b/js&css/extension/www.youtube.com/general/general.js @@ -512,6 +512,23 @@ extension.features.thumbnailsQuality = function (anything) { } }; +/*-------------------------------------------------------------- +# DISABLE VIDEO PLAYBACK ON HOVER +--------------------------------------------------------------*/ +extension.features.disableThumbnailPlayback = function (event) { + if (event instanceof Event) { + if (event.composedPath().some(elem => (elem.matches != null ? elem.matches("#content ytd-rich-item-renderer") : false) + )) { + event.stopImmediatePropagation(); + } + } else { + if (extension.storage.get('disable_thumbnail_playback') === true) { + window.addEventListener('mouseenter', this.disableThumbnailPlayback, true); + } else { + window.removeEventListener('mouseenter', this.disableThumbnailPlayback, true); + } + } +}; /*-------------------------------------------------------------- # OPEN VIDEOS IN A NEW TAB diff --git a/menu/skeleton-parts/general.js b/menu/skeleton-parts/general.js index 31b123eb6..26a9c38ae 100644 --- a/menu/skeleton-parts/general.js +++ b/menu/skeleton-parts/general.js @@ -176,6 +176,10 @@ extension.skeleton.main.layers.section.general = { text: 'hideAnimatedThumbnails', tags: 'preview' }, + disable_thumbnail_playback: { + component: 'switch', + text: 'disableThumbnailPlayback', + }, popup_window_buttons: { component: 'switch', text: 'popupWindowButtons',