Recommend this

Removes the recommendations for channels and videos on Youtube's main page.

  1. // ==UserScript==
  2. // @name Recommend this
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description Removes the recommendations for channels and videos on Youtube's main page.
  6. // @author You
  7. // @match https://www.youtube.com/
  8. // @grant none
  9. // @require http://code.jquery.com/jquery-latest.js
  10. // ==/UserScript==
  11. /* jshint -W097 */
  12. 'use strict';
  13.  
  14. var incriminating_selectors = [
  15. 'span:contains("Recommended channel for you")',
  16. 'span:contains("Want all the latest updates? Subscribe now.")',
  17. 'span:contains("Recommended videos for you")',
  18. 'span.branded-page-module-title-text:contains("Recommended")',
  19. ];
  20.  
  21. var judgeNode = function(node) {
  22. $node = $(node);
  23. incriminating_selectors.forEach(function(inc_s) {
  24. if ($node.find(inc_s).length)
  25. $node.hide()
  26. })
  27. };
  28.  
  29. var mo = new MutationObserver(function(mutations){
  30. mutations.forEach(function(mutation) {
  31. mutation.addedNodes.forEach(function(node){
  32. judgeNode(node);
  33. });
  34. });
  35. });
  36.  
  37. var rootNode = document.querySelector("#feed-main-what_to_watch > ol");
  38. //once for all the content initially loaded
  39. for (var i = 0; i < rootNode.children.length; i++)
  40. judgeNode(rootNode.children[i]);
  41. mo.observe(rootNode, {"childList": true});

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址