YouTube Header Relative Position

The top header will no longer scroll along with the page

  1. // ==UserScript==
  2. // @name YouTube Header Relative Position
  3. // @namespace https://github.com/valera5505
  4. // @description The top header will no longer scroll along with the page
  5. // @author Valery Kirichenko
  6. // @homepage https://github.com/valera5505/Relative-YouTube-Header
  7. // @match *://www.youtube.com/*
  8. // @version 1.0
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. function setMasthead() {
  13. var isFixed;
  14. if (window.location.href.indexOf("watch") != -1)
  15. isFixed = false;
  16. else
  17. isFixed = true;
  18.  
  19. document.getElementById("masthead-positioner").style.position = isFixed ? 'fixed' : 'relative';
  20. document.getElementById("masthead-positioner-height-offset").style.display = isFixed ? 'block' : "none";
  21. }
  22.  
  23. setMasthead();
  24.  
  25. // SPFdone is event of YouTube AJAX page loader. I want to have relative header
  26. // on video page, but normal header on other pages
  27. document.addEventListener("spfdone", function() {
  28. setMasthead();
  29. });