NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name YouBlock
// @namespace https://openuserjs.org/users/lednerg
// @description Hit 'Flag for Spam' to block users in YouTube chat
// @include http://*.youtube.com/*
// @include http://youtube.com/*
// @include https://*.youtube.com/*
// @include https://youtube.com/*
// @version .1
// @grant none
// ==/UserScript==
// All of the code below was written by darby.rathbone
var names = [
];
var listenForAllComments = function (e) {
if (e.target.querySelector) {
var allcomments = e.target.querySelector('#all-comments');
if (allcomments) {
allcomments.addEventListener('DOMNodeInserted', function (e) {
var flag = e.target.querySelector('button[data-action="flag"]'),
author = e.target.querySelector('.author'),
authortext = author ? author.textContent.trim() : '';
if (flag && authortext) {
flag.addEventListener('click', function (f) {
names.push(authortext);
});
}
if (authortext && names.some(function (f) {
return f === authortext;
})) {
e.target.style.display = 'none';
}
});
removeEventListener('DOMNodeInserted', listenForAllComments);
}
}
};
addEventListener('DOMNodeInserted', listenForAllComments);