Last active
August 29, 2015 14:25
-
-
Save darbicus/5f068a986b5d7ed3737d to your computer and use it in GitHub Desktop.
Youblock is a greasemonkey script to block YouTube live streaming spammers by clicking flag for spam.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name spammer filter | |
// @namespace spam | |
// @description created to filter people from youtube chat rooms | |
// @include https://www.youtube.com/* | |
// @version 1 | |
// @grant none | |
// ==/UserScript== | |
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() : '', | |
target = e.target; | |
if (flag && authortext) { | |
flag.addEventListener('click', function (f) { | |
names.push(authortext); | |
target.parentElement.removeChild(target); | |
}); | |
} | |
if (authortext && names.some(function (f) { | |
return f === authortext; | |
})) { | |
e.target.parentElement.removeChild(e.target); | |
} | |
}); | |
removeEventListener('DOMNodeInserted', listenForAllComments); | |
} | |
} | |
}; | |
addEventListener('DOMNodeInserted', listenForAllComments); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment