ytch/ytch.user.js

43 lines
1.6 KiB
JavaScript
Raw Normal View History

2016-02-21 13:21:34 -05:00
// ==UserScript==
// @name Youtube comment hider
// @namespace https://austenwares.com/gogs/stonewareslord/ytch
// @description Hides youtube comments that contain specified text
// @author stonewareslord
// @version 0.1
// @homepage https://austenwares.com/gogs/stonewareslord/ytch
// @include http://youtube.com/watch*
// @include https://youtube.com/watch*
2016-02-21 13:38:40 -05:00
// @include http://www.youtube.com/watch*
// @include https://www.youtube.com/watch*
// @run-at document-body
2016-02-21 13:21:34 -05:00
// ==/UserScript==
// Options
// Set this to 'hide' to hide comments that contain words
// Set this to 'dim' to dim comments that contain words
var hideCommentOrDimComment = 'hide';
// Set this to an array of words or phrases to check for
// All entries should be wrapped in '' or ""
// All entries except the last one should end in a comma after ' or "
var wordList = [
'Example first string',
'Example second string',
"Example third string (with quotes)",
'Example last string (no comma after tick)'
];
2016-02-21 13:38:40 -05:00
function clearComments(){
2016-02-21 13:21:34 -05:00
comments = document.querySelectorAll('.comment-item>.content>.comment-text>.comment-text-content');
for (var i = 0; i < comments.length; i++) {
for (var j = 0; j < wordList.length; j++) {
if (comments[i].textContent.includes(wordList[j])) {
commentToRemove=comments[i].parentNode.parentNode.parentNode;//.parentNode;
// Set the opacity to 40%
commentToRemove.style.opacity=.4;
// Remove the comment chain entirely
//commentToRemove.parentNode.removeChild(commentToRemove);
}
}
}
}
2016-02-21 13:38:40 -05:00
setInterval(clearComments, 1000);