nico_search_filter2

ニコニコ動画の検索結果にNGフィルターをかけて消去する

  1. // ==UserScript==
  2. // @name nico_search_filter2
  3. // @namespace http://catherine.v0cyc1pp.com/nico_search_filter2.user.js
  4. // @include https://www.nicovideo.jp/search/*
  5. // @author greg10
  6. // @run-at document-start
  7. // @license GPL 3.0
  8. // @version 2.0
  9. // @grant none
  10. // @description ニコニコ動画の検索結果にNGフィルターをかけて消去する
  11. // ==/UserScript==
  12.  
  13.  
  14. //================================
  15. // コンフィグ
  16. // - NGワードを設定してください
  17. var g_text = "しゃけみー,くっきーたん,おちゃめ機能";
  18. //================================
  19.  
  20.  
  21.  
  22.  
  23. var nglist = g_text.split(",");
  24.  
  25.  
  26. function main() {
  27. //$(".item").each(function() {
  28. document.querySelectorAll(".item").forEach(function(elem){
  29. //var str = $(this).text();
  30. var str = elem.innerText;
  31.  
  32. for ( var i = 0; i < nglist.length; ++i) {
  33. var ngword = nglist[i];
  34. if ( ngword == "" ) continue;
  35.  
  36. ngword = ngword.replace(/^\s+|\s+$/g, "");
  37.  
  38. var obj = new RegExp( ngword, "i");
  39. var index = str.search( obj );
  40. //var index = str.indexOf( ngword );
  41. if ( index != -1 ) {
  42. //$(this).hide();
  43. elem.style.display = "none";
  44. console.log("str="+str);
  45. }
  46. }
  47. });
  48. }
  49.  
  50. var observer = new MutationObserver(function(mutations) {
  51. observer.disconnect();
  52. main();
  53. observer.observe( document, config);
  54. });
  55.  
  56. //var config = { attributes: true, childList: true, characterData: true, subtree:true }
  57. var config = { childList: true, characterData: true, subtree:true }
  58.  
  59. observer.observe( document, config);