diff --git a/README.md b/README.md index 91913ef..54239ec 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,5 @@ # ytch Youtube comment hider + +###Installation +Drag ytch.user.js into Firefox (with Greasemonkey installed) or chrome (with Tampermonkey installed) diff --git a/ytch.user.js b/ytch.user.js new file mode 100644 index 0000000..2ba6969 --- /dev/null +++ b/ytch.user.js @@ -0,0 +1,40 @@ +// ==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);