2017-08-02 41 views
0

我想为Tampermonkey制作一个脚本,它将删除Youtube页面顶部的蓝色栏。用Tampermonkey删除“在Chrome中观看Youtube视频”吧

这是蓝条的源代码:

<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> 

如果我从this post正确理解,我必须使用badDivs,随着包含选择。

我的代码看起来是这样,但它不工作:

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

badDivs.parent().remove(); 

})(); 

有谁请帮助,使这项工作?

回答

0

您可以简单地这样删除它:

(function() { 
    'use strict'; 
    var ticker = document.getElementById('ticker-content'); 
    ticker.parentElement.removeChild(ticker); 
})(); 
相关问题