YouTube Thumbnail Viewer

Adds a button to view the thumbnail of a YouTube video!

სკრიპტის ინსტალაცია?
ავტორის შემოთავაზებული სკრიპტი

შეიძლება მოგეწონოს YouTube: Revert Icon Dropdown.

სკრიპტის ინსტალაცია
  1. // ==UserScript==
  2. // @name YouTube Thumbnail Viewer
  3. // @namespace https://greasyfork.org/en/users/1008366-trickyclock
  4. // @version 1.1.1
  5. // @description Adds a button to view the thumbnail of a YouTube video!
  6. // @author TrickyClock
  7. // @match https://www.youtube.com/*
  8. // @license MIT
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. var showInDescription = true
  13.  
  14. function updateUrl(button) {
  15. // Get the video ID from the URL
  16. var videoId = window.location.href.split('v=')[1];
  17. var ampersandPosition = videoId.indexOf('&');
  18. if (ampersandPosition !== -1) {
  19. videoId = videoId.substring(0, ampersandPosition);
  20. }
  21.  
  22. // Redirect to the thumbnail URL
  23. button.href = `https://i.ytimg.com/vi_webp/${videoId}/maxresdefault.webp`;
  24. }
  25.  
  26. function addButton() {
  27. var element = document.getElementById('below');
  28. if (showInDescription)
  29. element = document.getElementById("description-inline-expander").getElementsByTagName("ytd-structured-description-content-renderer")[0]
  30. if (element) {
  31. // Update the element
  32. if (!showInDescription)
  33. element.style.marginTop = '-4px';
  34.  
  35. // If the element exists, check if the button has already been added
  36. var viewThumbnailButton = document.getElementById('view-thumbnail-button');
  37. if (!viewThumbnailButton) {
  38. // If the button does not exist, create it
  39. viewThumbnailButton = document.createElement('a');
  40. viewThumbnailButton.innerHTML = 'View Thumbnail';
  41. viewThumbnailButton.style.textDecoration = 'none';
  42. viewThumbnailButton.style.display = 'inline-block';
  43. viewThumbnailButton.style.marginTop = showInDescription ? '10px' : '6px';
  44. viewThumbnailButton.style.marginBottom = '-2px';
  45. viewThumbnailButton.style.color = 'var(--yt-spec-text-primary)';
  46. viewThumbnailButton.style.backgroundColor = 'var(--yt-spec-badge-chip-background)';
  47. viewThumbnailButton.style.border = 'none';
  48. viewThumbnailButton.style.padding = '6px 8px';
  49. viewThumbnailButton.style.fontSize = '14px';
  50. viewThumbnailButton.style.borderRadius = '16px'; //'8px';
  51. viewThumbnailButton.id = 'view-thumbnail-button';
  52.  
  53. element.parentNode.insertBefore(viewThumbnailButton, element);
  54. }
  55.  
  56. updateUrl(viewThumbnailButton);
  57. }
  58. }
  59.  
  60. setInterval(() => {
  61. addButton();
  62. }, 1000);