New YouTube Obnoxious Bar Fix

Works as of August 2024, prevents the search bar from following as you scroll down the page

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        New YouTube Obnoxious Bar Fix
// @description Works as of August 2024, prevents the search bar from following as you scroll down the page
// @match        https://www.youtube.com/*
// @grant       none
// @version 0.0.16
// @namespace https://greasyfork.org/users/8233
// ==/UserScript==
function adjustBar(events, observer) {
    if (document.getElementById('frex-downbut') !== null) {
        observer.disconnect();
        return;
    }

    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;

    var downbut = document.createElement('button');
    downbut.id = 'frex-downbut';
    downbut.innerText = '\u25BC';

    downbut.style.background = 'none';
    downbut.style.color = 'red';
    downbut.style.border = 'none';

    var buttons = document.getElementById('masthead-container').querySelector('#buttons')
    buttons.parentElement.insertBefore(downbut, buttons);

    downbut.onclick = function () {
        var cont = document.getElementById('end').parentElement;
        window.scrollTo(0, Math.max(0, cont.offsetHeight - 10));
    };

    // downbut.click();
}

var observer = new MutationObserver(adjustBar);
observer.observe(document.body, { childList: true, subtree: true });