Skip to content

Instantly share code, notes, and snippets.

@willkuerlich
Last active March 31, 2024 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save willkuerlich/4ce6151748b118b3b1c1258e9adf3fd3 to your computer and use it in GitHub Desktop.
Save willkuerlich/4ce6151748b118b3b1c1258e9adf3fd3 to your computer and use it in GitHub Desktop.
violentmonkey - Youtube Thumbnail Replacer
// ==UserScript==
// @name Willkuerlich Youtube Thumbnail Replacer
// @namespace Willkuerlich Tools
// @match https://www.youtube.com/*
// @grant none
// @version 1.0
// @author Willkuerlich
// @description 31.3.2024, 16:56:26
// ==/UserScript==
const replaceImgUrl = 'https://media.istockphoto.com/id/1479180033/de/foto/digitales-auge-ki-digitales-konzept-der-k%C3%BCnstlichen-intelligenz.jpg?s=1024x1024&w=is&k=20&c=GFkgf0--ujAJU74Bp9WQfjBaLWisNImL37zct_kQO3c=';
console.log('Loaded Willkuerlich Youtube Thumbnail Replacer');
function replaceImgElemScr(className) {
const imgElems = document.getElementsByClassName(className);
for(let i = 0; i < imgElems.length; i++) {
const imgElem = imgElems[i];
imgElem.src = replaceImgUrl;
}
}
function replaceThumbnails() {
replaceImgElemScr('yt-core-image yt-core-image--fill-parent-height yt-core-image--fill-parent-width yt-core-image--content-mode-scale-aspect-fill');
replaceImgElemScr('yt-core-image yt-core-image--fill-parent-height yt-core-image--fill-parent-width yt-core-image--content-mode-scale-aspect-fit');
}
function initialize() {
console.info('DOM loaded');
replaceThumbnails();
setInterval(() => {
replaceThumbnails();
}, 100);
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initialize);
} else {
initialize();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment