ytch/ytch.user.js

41 lines
1.5 KiB
JavaScript

// ==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*
// @run-at document-start
// ==/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)'
];
function clearComments(words){
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);
}
}
}
}
setInterval(clearComments(wordList), 1000);