smaller preview images in the search results

This commit is contained in:
Pavel 2021-07-14 22:09:31 +03:00
parent 7b1a463bbf
commit ccd8d5a194

View File

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name YouTube Normal Thumbnails // @name YouTube Normal Thumbnails
// @namespace http://greasyfork.org // @namespace http://greasyfork.org
// @version 0.6.1 // @version 0.7.0
// @description Restores normal thumbnails size // @description Restores normal thumbnails size
// @author NeoCortex // @author NeoCortex
// @match *://www.youtube.com/* // @match *://www.youtube.com/*
@ -23,6 +23,12 @@
display: none !important; display: none !important;
} }
`.trim(); `.trim();
const commonStyles = `
ytd-video-renderer[use-prominent-thumbs] ytd-thumbnail.ytd-video-renderer {
min-width: 120px !important;
max-width: 240px !important;
}
`.trim();
class YoutubeThumbnailsFixer { class YoutubeThumbnailsFixer {
private oldPerRow?: number; private oldPerRow?: number;
@ -36,6 +42,7 @@
constructor() { constructor() {
this.installContentObserver(); this.installContentObserver();
this.installStyle(commonStyles);
} }
private installContentObserver(): void { private installContentObserver(): void {
@ -44,7 +51,7 @@
if (null !== this.target) { if (null !== this.target) {
this.observer?.disconnect(); this.observer?.disconnect();
this.installStyle(); this.installStyle(styleContent);
this.updateRowsCount(); this.updateRowsCount();
this.installVideoGridObserver(); this.installVideoGridObserver();
} }
@ -89,9 +96,9 @@
} }
} }
private installStyle(): void { private installStyle(contents: string): void {
let style = document.createElement('style'); let style = document.createElement('style');
style.innerHTML = styleContent; style.innerHTML = contents;
document.body.appendChild(style); document.body.appendChild(style);
} }