Nokakin

チャンネル動画の検索結果から有料動画を消すやつ。 当然AutoPagerizeにも対応

目前為 2017-02-20 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Nokakin
  3. // @namespace https://github.com/segabito/
  4. // @description チャンネル動画の検索結果から有料動画を消すやつ。 当然AutoPagerizeにも対応
  5. // @include http://ch.nicovideo.jp/search/*
  6. // @version 2.3.8
  7. // @grant none
  8. // @license Public Domain
  9. // @noframes
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. var monkey =
  14. (function() {
  15. var addStyle = function(styles, id) {
  16. var elm = document.createElement('style');
  17. elm.type = 'text/css';
  18. if (id) { elm.id = id; }
  19.  
  20. var text = styles.toString();
  21. text = document.createTextNode(text);
  22. elm.appendChild(text);
  23. var head = document.getElementsByTagName('head');
  24. head = head[0];
  25. head.appendChild(elm);
  26. return elm;
  27. };
  28.  
  29. addStyle(`
  30. .popular {
  31. background: #ffc !important;
  32. }
  33.  
  34. .popular2 {
  35. outline: 2px solid gold !important;
  36. outline-offset: -4px;
  37. }
  38.  
  39. .popular3 {
  40. font-weight: bolder !important;
  41. color: red;
  42. }
  43. `.trim(), 'Nokakin');
  44.  
  45.  
  46.  
  47. var update = function() {
  48. Array.apply(null, document.querySelectorAll('.ads')).forEach(function(elm) {
  49. elm.remove();
  50. });
  51.  
  52. Array.apply(null, document.querySelectorAll('.ppv')).forEach(function(ppv) {
  53. ppv.closest('.item').remove();
  54. });
  55.  
  56. //Array.apply(null, document.querySelectorAll('.item_right .title')).forEach(function(title) {
  57. // var item = title.closest('.item');
  58. // var text = title.textContent;
  59. // //window.console.log('title:', text, item);
  60. // //if (maybeNg.test(text)) {
  61. // // item.style.opacity = 0.5;
  62. // //}
  63. // //if (ng.test(text)) {
  64. // // item.style.display = 'none';
  65. // //}
  66. //});
  67.  
  68.  
  69. Array.apply(null, document.querySelectorAll('.item .comment var')).forEach(function(elm) {
  70. var item = elm.closest('.item');
  71. var numRes = parseInt((elm.textContent || '0').replace(/,/g, ''), 10);
  72. //window.console.log('numRes:', numRes, item);
  73. if (numRes < 5) {
  74. item.style.display = 'none';
  75. }
  76. if (numRes > 1000) {
  77. item.classList.add('popular');
  78.  
  79. }
  80. if (numRes > 5000) {
  81. item.classList.add('popular');
  82. item.classList.add('popular2');
  83. }
  84. if (numRes > 10000) {
  85. item.classList.add('popular');
  86. item.classList.add('popular2');
  87. item.classList.add('popular3');
  88. }
  89. });
  90. };
  91.  
  92. update();
  93.  
  94. document.body.addEventListener('AutoPagerize_DOMNodeInserted', update, false);
  95. }); // end of monkey
  96.  
  97. monkey();
  98. })();