New YouTube Obnoxious Bar Fix

Works as of 17-Oct-2021, prevents the search bar from following as you scroll down the page

目前為 2021-10-18 提交的版本,檢視 最新版本

// ==UserScript==
// @name        New YouTube Obnoxious Bar Fix
// @description Works as of 17-Oct-2021, prevents the search bar from following as you scroll down the page
// @include     https://www.youtube.com/*
// @grant       none
// @version 0.0.11
// @namespace https://gf.qytechs.cn/users/8233
// ==/UserScript==
function adjustBar(x)
{
  document.getElementById('masthead-container').style.position = 'absolute';
  //if above is 'absolute' and not 'static' this must be commented out or the header will overlap the vid
  //document.getElementById('page-manager').style['margin-top'] = 0;
  if(document.getElementById('frex-downbut') !== null)
    return true;

  var downbut = document.createElement('button');
  downbut.id = 'frex-downbut';
  downbut.innerHTML = '\u25BC';
  downbut.style.background = 'none';  
  downbut.style.color = 'red';
  downbut.style.border = 'none';
 
  var endnode = document.getElementById('end');
  endnode.parentElement.insertBefore(downbut, endnode);
  
  downbut.onclick = function () {
    var cont = document.getElementById('end').parentElement;
    window.scrollTo(0, Math.max(0, cont.offsetHeight - 10));
  };

  downbut.click();
  return false;
}

function doadjustments()
{
  //retry if its not done yet
  if(adjustBar() === false)
  {
    //this is a hack since it seems sometimes the above returns false
    //because it updated some old bar that YT throws away so we end up
    //with new unchanged bar? so try to lower changes of that in this way
    window.setTimeout(doadjustments, 250);
    window.setTimeout(doadjustments, 500);
    window.setTimeout(doadjustments, 1000);
  }
}

//do it that many times to make sure it hits the new? bar that YT creates
//without this it sometimes (somehow, very rarely too) ends up not changing
//the bar despite the if === false check that should make it run till it works
doadjustments();
window.setTimeout(doadjustments, 250);
window.setTimeout(doadjustments, 500);
window.setTimeout(doadjustments, 1000);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址