Advertisement
nzisaacnz

Remove youtube comment spam

Jul 18th, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Remove year comments
  3. // @namespace    http://tampermonkey.net/
  4. // @version      0.1
  5. // @description  remove the stupid "2018 anyone?" comments from youtube
  6. // @author       gilm.isaac@gmail.com
  7. // @match        https://www.youtube.com/*
  8. // @grant        none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12.     'use strict';
  13.  
  14.     var commentsToRemoveRegex = /[0-9k]{4}|\d{2}([^\d]\d{2}){2}|(0.25|0.5|1.25|2).*speed|january|february|march|april|may|june|july|august|september|october|november|december|i am from|anyone from|brazil/i; // fuck the brazilians too
  15.     function KillWithFire() {
  16.         var comments = document.querySelectorAll('ytd-comment-thread-renderer');
  17.         Array.prototype.filter.call(comments, (item) => commentsToRemoveRegex.test(item.querySelector('yt-formatted-string#content-text').innerText.replace(/[^0-9a-zA-Z]/g,'')) ? item : null).forEach((item) => item.parentNode.removeChild(item));
  18.     }
  19.  
  20.     setInterval(KillWithFire, 100)
  21. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement