Last active
August 31, 2017 15:18
-
-
Save DropSnorz/1d4ce2f1c29ded0c87c53dad32002c68 to your computer and use it in GitHub Desktop.
Greasemonkey script to remove Youtube trending links
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Youtube trendings remover | |
// @namespace com.dropsnorz.gm | |
// @description Remove all Youtube trendings links and references | |
// @include *://www.youtube.com/* | |
// @author Dropsnorz | |
// @version 1 | |
// @grant none | |
// ==/UserScript== | |
function removeTrendings(){ | |
Array.prototype.forEach.call(document.querySelectorAll("ytd-guide-entry-renderer a[href=\"/feed/trending\"]"), function( node ) { | |
node.parentNode.parentNode.removeChild(node.parentNode); | |
}); | |
Array.prototype.forEach.call(document.querySelectorAll("*[href=\"/feed/trending\"]"), function( node ) { | |
node.parentNode.removeChild(node); | |
}); | |
} | |
//Removes trendings after each title tag updates | |
new MutationObserver(function(mutations) { | |
removeTrendings(); | |
}).observe( | |
document.querySelector('title'), | |
{ subtree: true, characterData: true, childList: true } | |
); | |
removeTrendings(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment