youtube_search_filter4

Hide videos including specified words in the Youtube search results.

  1. // ==UserScript==
  2. // @name youtube_search_filter4
  3. // @namespace https://catherine.v0cyc1pp.com/
  4. // @include https://www.youtube.com/*
  5. // @author greg10
  6. // @run-at document-start
  7. // @license GPL 3.0
  8. // @version 4.0
  9. // @grant none
  10. // @description Hide videos including specified words in the Youtube search results.
  11. // ==/UserScript==
  12.  
  13.  
  14. //================================
  15. // Configurations
  16. // - specify texts you don't want to see.
  17. var g_list = [
  18. "AKB",
  19. "AKB",
  20. "HikakinTV",
  21. "HikakinGames",
  22. "はじめしゃちょー",
  23. "NiziU",
  24. ];
  25. //================================
  26.  
  27.  
  28.  
  29.  
  30. function main() {
  31.  
  32. //$("div.yt-lockup-content").each(function() {
  33. document.querySelectorAll("ytd-video-renderer,ytd-channel-renderer,ytd-grid-video-renderer,ytd-playlist-renderer").forEach(function(elem) {
  34. //var str = $(this).text();
  35. var str = elem.innerText;
  36. //console.log("str="+str);
  37.  
  38. for (var i = 0; i < g_list.length; ++i) {
  39. var ngword = g_list[i];
  40. if (ngword == "") continue;
  41.  
  42. ngword = ngword.replace(/^\s+|\s+$/g, "");
  43.  
  44. var obj = new RegExp(ngword, "i");
  45. var index = str.search(obj);
  46. //var index = str.indexOf( ngword );
  47. if (index != -1) {
  48. //$(this).parent("div").parent("div").parent("li").hide();
  49. elem.style.display = "none";
  50. //console.log("str="+str);
  51. }
  52. }
  53. });
  54. }
  55.  
  56. var observer = new MutationObserver(function(mutations) {
  57. observer.disconnect();
  58. main();
  59. observer.observe(document, config);
  60. });
  61.  
  62. //var config = { attributes: true, childList: true, characterData: true, subtree:true }
  63. var config = {
  64. childList: true,
  65. characterData: true,
  66. subtree: true
  67. }
  68.  
  69. observer.observe(document, config);

QingJ © 2025

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