Advertisement
alien_fx_fiend

YouTube UserScript ProgressBar Notch, BG Colors etc. (Chapter Marks Fixed !!!) FINAL

Jan 1st, 2025
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 5.42 KB | Source Code | 0 0
  1. /* Start JS 23px notch, buffer/ played colors, 10px height Gemini2FlashProThinkingAI Assist Orig Claude3.5Sonnet */
  2. // First, inject the CSS
  3. const style = document.createElement('style');
  4. style.textContent = `
  5. .custom-youtube-notch {
  6.     position: absolute;
  7.     width: 23px;
  8.     height: 23px;
  9.     background-color: black;
  10.     border: 2px solid white;
  11.     border-radius: 50%;
  12.     z-index: 999999;
  13.     pointer-events: none;
  14.     transform: translateX(-50%) translateY(-50%);
  15. }
  16.  
  17. /* Make buffered progress hot pink */
  18. .html5-load-progress, .ytp-load-progress {
  19.     background-color: black !important;
  20. }
  21.  
  22. /* Make played progress indigo */
  23. .html5-play-progress, .ytp-play-progress {
  24.     background-color: indigo !important;
  25. }
  26.  
  27. .ytp-chapters-container, .ytp-chapter-hover-container {
  28. z-index: 9999999 !important;
  29. position: relative !important;
  30. left: 0 !important;
  31. height: 100% !important;
  32. border-left: 2px solid black !important;
  33. }
  34.  
  35. /* Make unplayed progress yellow */
  36. .ytp-progress-bar-container {
  37.     background: yellow !important;
  38.     opacity: 0.6 !important;
  39.     /*opacity: 1.0 !important;*/
  40. }
  41.  
  42. /* Make sure the hover preview also matches indigo */
  43. .html5-hover-progress, .ytp-hover-progress {
  44.     background-color: indigo !important;
  45. }
  46.  
  47. /* Ensure proper layering */
  48. .html5-progress-list, .ytp-progress-list {
  49.     z-index: 99998 !important;
  50. }
  51.  
  52. /* Make progress bar thicker */
  53. .html5-progress-bar-container, .ytp-progress-bar-container {
  54.     height: 10px !important;
  55. }
  56.  
  57. .html5-progress-bar, .ytp-progress-bar {
  58.     height: 10px !important;
  59. }
  60.  
  61. .html5-progress-list, .ytp-progress-list {
  62.     height: 10px !important;
  63. }
  64.  
  65. .ytp-progress-bar .ytp-play-progress,
  66. .ytp-progress-bar .ytp-load-progress,
  67. .ytp-progress-bar .ytp-hover-progress {
  68.     height: 10px !important;
  69. }
  70.  
  71. /* Update these styles in your JavaScript */
  72. /* Make played progress indigo */
  73. .ytp-progress-bar .ytp-play-progress,
  74. .ytp-progress-bar-container .ytp-play-progress,
  75. .ytp-progress-bar .ytp-play-progress.ytp-swatch-background-color {
  76.     background: indigo !important;
  77.     background-color: indigo !important;
  78. }
  79.  
  80. /* Adjust the scrubber container for the thicker bar */
  81. .html5-scrubber-container, .ytp-scrubber-container {
  82.     height: 10px !important;
  83. }
  84.  
  85. /* When hovering, make it even thicker */
  86. .ytp-progress-bar-container:hover {
  87.     height: 15px !important;
  88. }
  89.  
  90. .ytp-progress-bar-container:hover .ytp-progress-bar,
  91. .ytp-progress-bar-container:hover .ytp-progress-list,
  92. .ytp-progress-bar-container:hover .ytp-play-progress,
  93. .ytp-progress-bar-container:hover .ytp-load-progress,
  94. .ytp-progress-bar-container:hover .ytp-hover-progress {
  95.     height: 15px !important;
  96. }
  97. `;
  98. document.head.appendChild(style);
  99.  
  100. function enforceProgressBarColor() {
  101.     const playProgress = document.querySelector('.ytp-play-progress');
  102.     if (playProgress) {
  103.         playProgress.style.setProperty('background', 'indigo', 'important');
  104.         playProgress.style.setProperty('background-color', 'indigo', 'important');
  105.     }
  106.     /*if (progressBar) {
  107.          progressBar.style.setProperty('background', 'yellow', 'important');
  108.         progressBar.style.setProperty('background-color', 'yellow', 'important');
  109.  
  110. progressBar.style.setProperty('opacity', '1.0', 'important');
  111.     }*/
  112. }
  113.  
  114. // Function to create or update the notch
  115. function updateNotch() {
  116.     let progressBar = document.querySelector('.ytp-progress-bar');
  117.     let player = document.querySelector('.html5-main-video');
  118.     let progressBarContainer = document.querySelector('.ytp-progress-bar-container');
  119.    
  120.     if (!progressBar || !player || !progressBarContainer) return;
  121.  
  122.     // Create notch if it doesn't exist
  123.     let notch = document.querySelector('.custom-youtube-notch');
  124.     if (!notch) {
  125.         notch = document.createElement('div');
  126.         notch.className = 'custom-youtube-notch';
  127.         progressBarContainer.appendChild(notch);
  128.     }
  129.  
  130.     // Calculate position
  131.     let progress = (player.currentTime / player.duration) * 100;
  132.     let progressBarRect = progressBar.getBoundingClientRect();
  133.     let position = (progressBarRect.width * progress) / 100;
  134.  
  135.     // Update notch position
  136.     notch.style.left = `${position}px`;
  137.     notch.style.top = '50%';
  138.     notch.style.display = 'block';
  139. }
  140.  
  141. // Function to start the interval
  142. function startNotchUpdate() {
  143.     // Initial update
  144.     updateNotch();
  145.     //enforceProgressBarColor();
  146.    
  147.     // Set interval for updates
  148.     return setInterval(updateNotch, 1000);
  149. }
  150.  
  151. // Function to initialize and handle page changes
  152. function initialize() {
  153.     let interval;
  154.  
  155.     // Observer for detecting player load
  156.     const observer = new MutationObserver((mutations) => {
  157.         if (document.querySelector('.html5-main-video')) {
  158.             if (!interval) {
  159.                 interval = startNotchUpdate();
  160.             }
  161.         }
  162.     });
  163.  
  164.     // Start observing
  165.     observer.observe(document.body, {
  166.         childList: true,
  167.         subtree: true
  168.     });
  169.  
  170.     // Handle navigation (for YouTube's SPA nature)
  171.     let lastUrl = location.href;
  172.     new MutationObserver(() => {
  173.         const url = location.href;
  174.         if (url !== lastUrl) {
  175.             lastUrl = url;
  176.             clearInterval(interval);
  177.             interval = startNotchUpdate();
  178.         }
  179.     }).observe(document.body, {subtree: true, childList: true});
  180. }
  181.  
  182. // Start the script
  183. initialize();
  184. /* End JS 23px notch, buffer/ played colors, 10px height */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement