Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Hide top bar on video pages ........... works but takes forever to load
- // @namespace http://tampermonkey.net/
- // @version 0.1
- // @description Hides the top bar on YouTube video pages
- // @author Your Name
- // @match *://www.youtube.com/*
- // @grant none
- // ==/UserScript==
- (function() {
- 'use strict';
- // Get the top bar element
- var topBar = document.getElementById('masthead-container');
- // Check if we're on a video page
- function checkPage() {
- if (window.location.href.indexOf('/watch') > -1) {
- // If so, hide the top bar
- if (topBar) {
- topBar.style.display = 'none';
- }
- } else {
- // If we're not on a video page, show the top bar
- if (topBar) {
- topBar.style.display = 'block';
- }
- }
- }
- // Create a MutationObserver to continuously check for changes to the page
- var observer = new MutationObserver(function(mutations) {
- mutations.forEach(function(mutation) {
- if (mutation.type === 'childList') {
- checkPage();
- }
- });
- });
- // Start observing the document for changes
- observer.observe(document.body, { childList: true, subtree: true });
- // Check the page initially
- checkPage();
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement