Advertisement
alien_fx_fiend

YouTube UserScript ProgressBar Notch + BG Colors (RightMost ChapterMark is Fixed!!) *FINALRELEASE*

Jan 1st, 2025 (edited)
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 6.17 KB | Source Code | 0 0
  1. /* Start JS 23px notch, buffer/ played colors, 10px height */
  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. /* Style the chapter mark separators using ::before */
  28. .ytp-chapters-container::before,
  29. .ytp-chapter-hover-container::before {
  30.     content: ''; /* Required for pseudo-elements */
  31.     position: absolute;
  32.     top: 0;
  33.     bottom: 0;
  34.     left: 0; /* Position the separator at the left edge */
  35.     width: 4px; /* Adjust the width of the separator */
  36.     background-color: green; /* Adjust the color of the separator */
  37.     z-index: 1; /* Ensure it's above the background */
  38. }
  39.  
  40. /* Remove the border-left from the containers */
  41. .ytp-chapters-container, .ytp-chapter-hover-container {
  42.     z-index: 9999999 !important;
  43.     position: relative;
  44.     left: 0;
  45.     height: 100%;
  46.     /* REMOVE THIS LINE: border-left: 2px solid black !important; */
  47. }
  48.  
  49. /* .ytp-chapters-container, .ytp-chapter-hover-container, .ytp-chapters, .ytp-chapter {
  50. z-index: 9999999 !important;
  51. position: relative !important;
  52. left: 0 !important;
  53. height: 100% !important;
  54. border-left: 4px solid black !important;
  55. opacity: 1.0 !important;
  56. } */
  57.  
  58. /* Make unplayed progress yellow */
  59. .ytp-progress-bar-container {
  60.     background-color: yellow !important;
  61.     opacity: 0.6 !important;
  62.     /*opacity: 1.0 !important;*/
  63. }
  64.  
  65. /* Make sure the hover preview also matches indigo */
  66. .html5-hover-progress, .ytp-hover-progress {
  67.     background-color: indigo !important;
  68. }
  69.  
  70. /* Ensure proper layering */
  71. .html5-progress-list, .ytp-progress-list {
  72.     z-index: 99998 !important;
  73. }
  74.  
  75. /* Make progress bar thicker */
  76. .html5-progress-bar-container, .ytp-progress-bar-container {
  77.     height: 10px !important;
  78. }
  79.  
  80. .html5-progress-bar, .ytp-progress-bar {
  81.     height: 10px !important;
  82. }
  83.  
  84. .html5-progress-list, .ytp-progress-list {
  85.     height: 10px !important;
  86. }
  87.  
  88. .ytp-progress-bar .ytp-play-progress,
  89. .ytp-progress-bar .ytp-load-progress,
  90. .ytp-progress-bar .ytp-hover-progress {
  91.     height: 10px !important;
  92. }
  93.  
  94. /* Update these styles in your JavaScript */
  95. /* Make played progress indigo */
  96. .ytp-progress-bar .ytp-play-progress,
  97. .ytp-progress-bar-container .ytp-play-progress,
  98. .ytp-progress-bar .ytp-play-progress.ytp-swatch-background-color {
  99.     background: indigo !important;
  100.     background-color: indigo !important;
  101. }
  102.  
  103. /* Adjust the scrubber container for the thicker bar */
  104. .html5-scrubber-container, .ytp-scrubber-container {
  105.     height: 10px !important;
  106. }
  107.  
  108. /* When hovering, make it even thicker */
  109. .ytp-progress-bar-container:hover {
  110.     height: 15px !important;
  111. }
  112.  
  113. .ytp-progress-bar-container:hover .ytp-progress-bar,
  114. .ytp-progress-bar-container:hover .ytp-progress-list,
  115. .ytp-progress-bar-container:hover .ytp-play-progress,
  116. .ytp-progress-bar-container:hover .ytp-load-progress,
  117. .ytp-progress-bar-container:hover .ytp-hover-progress {
  118.     height: 15px !important;
  119. }
  120. `;
  121. document.head.appendChild(style);
  122.  
  123. function enforceProgressBarColor() {
  124.     const playProgress = document.querySelector('.ytp-play-progress');
  125.     if (playProgress) {
  126.         playProgress.style.setProperty('background', 'indigo', 'important');
  127.         playProgress.style.setProperty('background-color', 'indigo', 'important');
  128.     }
  129.     /*if (progressBar) {
  130.          progressBar.style.setProperty('background', 'yellow', 'important');
  131.         progressBar.style.setProperty('background-color', 'yellow', 'important');
  132.  
  133. progressBar.style.setProperty('opacity', '1.0', 'important');
  134.     }*/
  135. }
  136.  
  137. // Function to create or update the notch
  138. function updateNotch() {
  139.     let progressBar = document.querySelector('.ytp-progress-bar');
  140.     let player = document.querySelector('.html5-main-video');
  141.     let progressBarContainer = document.querySelector('.ytp-progress-bar-container');
  142.    
  143.     if (!progressBar || !player || !progressBarContainer) return;
  144.  
  145.     // Create notch if it doesn't exist
  146.     let notch = document.querySelector('.custom-youtube-notch');
  147.     if (!notch) {
  148.         notch = document.createElement('div');
  149.         notch.className = 'custom-youtube-notch';
  150.         progressBarContainer.appendChild(notch);
  151.     }
  152.  
  153.     // Calculate position
  154.     let progress = (player.currentTime / player.duration) * 100;
  155.     let progressBarRect = progressBar.getBoundingClientRect();
  156.     let position = (progressBarRect.width * progress) / 100;
  157.  
  158.     // Update notch position
  159.     notch.style.left = `${position}px`;
  160.     notch.style.top = '50%';
  161.     notch.style.display = 'block';
  162. }
  163.  
  164. // Function to start the interval
  165. function startNotchUpdate() {
  166.     // Initial update
  167.     updateNotch();
  168.     //enforceProgressBarColor();
  169.    
  170.     // Set interval for updates
  171.     return setInterval(updateNotch, 1000);
  172. }
  173.  
  174. // Function to initialize and handle page changes
  175. function initialize() {
  176.     let interval;
  177.  
  178.     // Observer for detecting player load
  179.     const observer = new MutationObserver((mutations) => {
  180.         if (document.querySelector('.html5-main-video')) {
  181.             if (!interval) {
  182.                 interval = startNotchUpdate();
  183.             }
  184.         }
  185.     });
  186.  
  187.     // Start observing
  188.     observer.observe(document.body, {
  189.         childList: true,
  190.         subtree: true
  191.     });
  192.  
  193.     // Handle navigation (for YouTube's SPA nature)
  194.     let lastUrl = location.href;
  195.     new MutationObserver(() => {
  196.         const url = location.href;
  197.         if (url !== lastUrl) {
  198.             lastUrl = url;
  199.             clearInterval(interval);
  200.             interval = startNotchUpdate();
  201.         }
  202.     }).observe(document.body, {subtree: true, childList: true});
  203. }
  204.  
  205. // Start the script
  206. initialize();
  207. /* End JS 23px notch, buffer/ played colors, 10px height */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement