Advertisement
alien_fx_fiend

YouTube ProgressBar Notch + Rainbow SeekBar + Bigger Bar/Chapter Marks

Jan 25th, 2025
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 7.10 KB | Source Code | 0 0
  1. // ==UserScript==
  2. // @name         YouTube Progress Notch
  3. // @namespace    http://tampermonkey.net/
  4. // @version      1.0
  5. // @description  Adds a persistent notch to YouTube progress bar
  6. // @match        https://www.youtube.com/*
  7. // @grant        none
  8. // ==/UserScript==
  9.  
  10. (function() {
  11.     'use strict';
  12.     // [Paste the above script here]
  13.     /* Start JS 23px notch, buffer/ played colors, 10px height */
  14. // First, inject the CSS
  15. const style = document.createElement('style');
  16. style.textContent = `
  17. .custom-youtube-notch {
  18.     position: absolute;
  19.     width: 23px;
  20.     height: 23px;
  21.     background-color: black;
  22.     border: 2px solid white;
  23.     border-radius: 50%;
  24.     z-index: 999999;
  25.     pointer-events: none;
  26.     /* box-shadow: 0 0 8px indigo; */ /* Add outer glow */
  27.     -moz-box-shadow:0 0 15px #c00!important;
  28.     -webkit-box-shadow:0 0 15px #c00!important;
  29.     box-shadow:0 0 15px #ffffff!important;
  30.     transform: translateX(-50%) translateY(-50%);
  31. }
  32.  
  33. /* Make buffered progress hot pink */
  34. .html5-load-progress, .ytp-load-progress {
  35.     background-color: black !important;
  36. }
  37.  
  38. /* Make played progress rainbow gradient */
  39. .html5-play-progress, .ytp-play-progress {
  40.     background: linear-gradient(to right, red, orange, yellow, green, blue, indigo, violet); /* Rainbow gradient */
  41.     background-color: transparent !important; /* Override any solid background-color */
  42. }
  43.  
  44. /* Style the chapter mark separators using ::before */
  45. .ytp-chapters-container::before,
  46. .ytp-chapter-hover-container::before {
  47.     content: ''; /* Required for pseudo-elements */
  48.     position: absolute;
  49.     top: 0;
  50.     bottom: 0;
  51.     left: 0; /* Position the separator at the left edge */
  52.     width: 4px; /* Adjust the width of the separator */
  53.     background-color: green; /* Adjust the color of the separator */
  54.     z-index: 1; /* Ensure it's above the background */
  55. }
  56.  
  57. /* Remove the border-left from the containers */
  58. .ytp-chapters-container, .ytp-chapter-hover-container {
  59.     z-index: 9999999 !important;
  60.     position: relative;
  61.     left: 0;
  62.     height: 100%;
  63.     /* REMOVE THIS LINE: border-left: 2px solid black !important; */
  64. }
  65.  
  66. /* .ytp-chapters-container, .ytp-chapter-hover-container, .ytp-chapters, .ytp-chapter {
  67. z-index: 9999999 !important;
  68. position: relative !important;
  69. left: 0 !important;
  70. height: 100% !important;
  71. border-left: 4px solid black !important;
  72. opacity: 1.0 !important;
  73. } */
  74.  
  75. /* Make unplayed progress yellow */
  76. .ytp-progress-bar-container {
  77.     background-color: yellow !important;
  78.     opacity: 1.0 !important;
  79.     /*opacity: 1.0 0.6 !important;*/
  80. }
  81.  
  82. /* Make sure the hover preview also matches indigo */
  83. .html5-hover-progress, .ytp-hover-progress {
  84.     background-color: indigo !important;
  85. }
  86.  
  87. /* Ensure proper layering */
  88. .html5-progress-list, .ytp-progress-list {
  89.     z-index: 99998 !important;
  90. }
  91.  
  92. /* Make progress bar thicker */
  93. .html5-progress-bar-container, .ytp-progress-bar-container {
  94.     height: 12px !important;
  95. }
  96.  
  97. .html5-progress-bar, .ytp-progress-bar {
  98.     height: 12px !important;
  99. }
  100.  
  101. .html5-progress-list, .ytp-progress-list {
  102.     height: 12px !important;
  103. }
  104.  
  105. .ytp-progress-bar .ytp-play-progress,
  106. .ytp-progress-bar .ytp-load-progress,
  107. .ytp-progress-bar .ytp-hover-progress {
  108.     height: 12px !important;
  109. }
  110.  
  111. /* Update these styles in your JavaScript */
  112. /* Make played progress rainbow gradient */
  113. .ytp-progress-bar .ytp-play-progress,
  114. .ytp-progress-bar-container .ytp-play-progress,
  115. .ytp-progress-bar .ytp-play-progress.ytp-swatch-background-color {
  116.     background: linear-gradient(to right, red, orange, yellow, green, blue, indigo, violet) !important; /* Rainbow gradient */
  117.     background-color: transparent !important; /* Override any solid background-color */
  118. }
  119.  
  120. /* Adjust the scrubber container for the thicker bar */
  121. .html5-scrubber-container, .ytp-scrubber-container {
  122.     height: 12px !important;
  123. }
  124.  
  125. /* When hovering, make it even thicker */
  126. .ytp-progress-bar-container:hover {
  127.     height: 15px !important;
  128. }
  129.  
  130. .ytp-progress-bar-container:hover .ytp-progress-bar,
  131. .ytp-progress-bar-container:hover .ytp-progress-list,
  132. .ytp-progress-bar-container:hover .ytp-play-progress,
  133. .ytp-progress-bar-container:hover .ytp-load-progress,
  134. .ytp-progress-bar-container:hover .ytp-hover-progress {
  135.     height: 15px !important;
  136. }
  137. `;
  138. document.head.appendChild(style);
  139.  
  140. function enforceProgressBarColor() {
  141.     const playProgress = document.querySelector('.ytp-play-progress');
  142.     if (playProgress) {
  143.         playProgress.style.setProperty('background', 'linear-gradient(to right, red, orange, yellow, green, blue, indigo, violet)', 'important');
  144.         playProgress.style.setProperty('background-color', 'transparent', 'important');
  145.     }
  146.     /*if (progressBar) {
  147.          progressBar.style.setProperty('background', 'yellow', 'important');
  148.         progressBar.style.setProperty('background-color', 'yellow', 'important');
  149.  
  150. progressBar.style.setProperty('opacity', '1.0', 'important');
  151.     }*/
  152. }
  153.  
  154. // Function to create or update the notch
  155. function updateNotch() {
  156.     let progressBar = document.querySelector('.ytp-progress-bar');
  157.     let player = document.querySelector('.html5-main-video');
  158.     let progressBarContainer = document.querySelector('.ytp-progress-bar-container');
  159.  
  160.     if (!progressBar || !player || !progressBarContainer) return;
  161.  
  162.     // Create notch if it doesn't exist
  163.     let notch = document.querySelector('.custom-youtube-notch');
  164.     if (!notch) {
  165.         notch = document.createElement('div');
  166.         notch.className = 'custom-youtube-notch';
  167.         progressBarContainer.appendChild(notch);
  168.     }
  169.  
  170.     // Calculate position
  171.     let progress = (player.currentTime / player.duration) * 100;
  172.     let progressBarRect = progressBar.getBoundingClientRect();
  173.     let position = (progressBarRect.width * progress) / 100;
  174.  
  175.     // Update notch position
  176.     notch.style.left = `${position}px`;
  177.     notch.style.top = '50%';
  178.     notch.style.display = 'block';
  179. }
  180.  
  181. // Function to start the interval
  182. function startNotchUpdate() {
  183.     // Initial update
  184.     updateNotch();
  185.     //enforceProgressBarColor();
  186.  
  187.     // Set interval for updates
  188.     return setInterval(updateNotch, 1000);
  189. }
  190.  
  191. // Function to initialize and handle page changes
  192. function initialize() {
  193.     let interval;
  194.  
  195.     // Observer for detecting player load
  196.     const observer = new MutationObserver((mutations) => {
  197.         if (document.querySelector('.html5-main-video')) {
  198.             if (!interval) {
  199.                 interval = startNotchUpdate();
  200.             }
  201.         }
  202.     });
  203.  
  204.     // Start observing
  205.     observer.observe(document.body, {
  206.         childList: true,
  207.         subtree: true
  208.     });
  209.  
  210.     // Handle navigation (for YouTube's SPA nature)
  211.     let lastUrl = location.href;
  212.     new MutationObserver(() => {
  213.         const url = location.href;
  214.         if (url !== lastUrl) {
  215.             lastUrl = url;
  216.             clearInterval(interval);
  217.             interval = startNotchUpdate();
  218.         }
  219.     }).observe(document.body, {subtree: true, childList: true});
  220. }
  221.  
  222. // Start the script
  223. initialize();
  224. /* End JS 23px notch, buffer/ played colors, 10px height */
  225. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement