🏠 返回首頁 

Greasy Fork is available in English.

youtube_search_filter4

Hide videos including specified words in the Youtube search r###lts.

  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 r###lts.
  11. // ==/UserScript==
  12. //================================
  13. // Configurations
  14. // - specify texts you don't want to see.
  15. var g_list = [
  16. "AKB",
  17. "AKB",
  18. "HikakinTV",
  19. "HikakinGames",
  20. "はじめしゃちょー",
  21. "NiziU",
  22. ];
  23. //================================
  24. function main() {
  25. //$("div.yt-lockup-content").each(function() {
  26. document.querySelectorAll("ytd-video-renderer,ytd-channel-renderer,ytd-grid-video-renderer,ytd-playlist-renderer").forEach(function(elem) {
  27. //var str = $(this).text();
  28. var str = elem.innerText;
  29. //console.log("str="+str);
  30. for (var i = 0; i < g_list.length; ++i) {
  31. var ngword = g_list[i];
  32. if (ngword == "") continue;
  33. ngword = ngword.replace(/^\s+|\s+$/g, "");
  34. var obj = new RegExp(ngword, "i");
  35. var index = str.search(obj);
  36. //var index = str.indexOf( ngword );
  37. if (index != -1) {
  38. //$(this).parent("div").parent("div").parent("li").hide();
  39. elem.style.display = "none";
  40. //console.log("str="+str);
  41. }
  42. }
  43. });
  44. }
  45. var observer = new MutationObserver(function(mutations) {
  46. observer.disconnect();
  47. main();
  48. observer.observe(document, config);
  49. });
  50. //var config = { attributes: true, childList: true, characterData: true, subtree:true }
  51. var config = {
  52. childList: true,
  53. characterData: true,
  54. subtree: true
  55. }
  56. observer.observe(document, config);