0

I am trying to make a script for Tampermonkey which removes the blue bar at the top of a Youtube page.

This is the source code for the blue bar:

 <div id="ticker-content">
        <div class="yt-alert yt-alert-default yt-alert-info  " id="ticker">  <div class="yt-alert-icon">
        <span class="icon master-sprite yt-sprite"></span>
      </div>
    <div class="yt-alert-content" role="alert">    <div tabindex="0" class="yt-alert-message">
                Watch YouTube videos with Chrome. &nbsp; &nbsp; <a href="https://www.google.com/chrome/browser/desktop/index.html?brand=NDCM&amp;utm_source=all-pushdown-yt&amp;utm_medium=yt-pushdown&amp;utm_campaign=yt-watch">Yes, get Chrome now</a>.
        </div>
    </div><div class="yt-alert-buttons"><button class="yt-uix-button yt-uix-button-size-default yt-uix-button-close close yt-uix-close" aria-label="Close" onclick="yt.www.masthead.dismissChromeAlert();return false;" type="button" data-close-parent-class="yt-alert"><span class="yt-uix-button-content">Close</span></button></div></div>
      </div>

If i understand correctly from this post, i have to use badDivs, along with the contains selector.

My code looks like this, but it doesn't work:

(function() {
    'use strict';
var badDivs = $("div div:contains('ticker-content')");

badDivs.parent ().remove ();

})();

Could anybody please help make this work?

1 Answers1

0

You can simply remove it like this:

(function() {
    'use strict';
    var ticker = document.getElementById('ticker-content');
    ticker.parentElement.removeChild(ticker);
})();
d2718nis
  • 1,279
  • 9
  • 13