YoutTube Thumbnail Image Resolution Selector with Buttons

Add buttons for all resolutions when retrieving YouTube thumbnail images

  1. // ==UserScript==
  2. // @name YoutTube Thumbnail Image Resolution Selector with Buttons
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1.1
  5. // @description Add buttons for all resolutions when retrieving YouTube thumbnail images
  6. // @author satandidnowrong
  7. // @match https://i.ytimg.com/*
  8. // @grant none
  9. // @license Creative Commons Attribution-NonCommercial 4.0 International License
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14. const parts = window.location.pathname.split('/');
  15. const newX = 'vi';
  16. const newY = parts[2];
  17.  
  18. const resolutions = [
  19. "maxresdefault.jpg",
  20. "sddefault.jpg",
  21. "hqdefault.jpg",
  22. "mqdefault.jpg",
  23. "default.jpg",
  24. "hq720.jpg"
  25. ];
  26.  
  27. const buttonsContainer = document.createElement('div');
  28. buttonsContainer.style.position = 'fixed';
  29. buttonsContainer.style.top = '10px';
  30. buttonsContainer.style.left = '10px';
  31. document.body.appendChild(buttonsContainer);
  32.  
  33. resolutions.forEach(resolution => {
  34. const button = document.createElement('button');
  35. button.textContent = resolution.split('.')[0].toUpperCase();
  36. button.onclick = () => {
  37. const newUrl = `https://i.ytimg.com/${newX}/${newY}/${resolution}`;
  38. window.location.href = newUrl;
  39. };
  40. buttonsContainer.appendChild(button);
  41. });
  42. })();