Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions js&css/extension/www.youtube.com/general/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -542,8 +542,9 @@ extension.features.thumbnailsQuality = function (anything) {
--------------------------------------------------------------*/
extension.features.disableThumbnailPlayback = function (event) {
if (event instanceof Event) {
if (event.composedPath().some(elem => (elem.matches != null && elem.matches('#content.ytd-rich-item-renderer, #contents.ytd-item-section-renderer'))
)) {
if (event.composedPath().some(elem => (elem.matches != null && elem.matches(
'#content.ytd-rich-item-renderer, #contents.ytd-item-section-renderer, #dismissible.ytd-compact-video-renderer'
)))) {
event.stopImmediatePropagation();
}
} else {
Expand Down
29 changes: 29 additions & 0 deletions tests/unit/disable-thumbnail-playback.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Test for Issue #3639: Disable video playback on hover not working on sidebar

const fs = require('fs');
const path = require('path');

describe('Disable Thumbnail Playback (#3639)', () => {
let generalContent;

beforeAll(() => {
const filePath = path.join(__dirname, '../../js&css/extension/www.youtube.com/general/general.js');
generalContent = fs.readFileSync(filePath, 'utf8');
});

test('should match home page grid items', () => {
expect(generalContent).toContain('#content.ytd-rich-item-renderer');
});

test('should match search results items', () => {
expect(generalContent).toContain('#contents.ytd-item-section-renderer');
});

test('should match sidebar compact video items', () => {
expect(generalContent).toContain('#dismissible.ytd-compact-video-renderer');
});

test('should use stopImmediatePropagation to block hover playback', () => {
expect(generalContent).toContain('event.stopImmediatePropagation()');
});
});
Loading