// ==UserScript==
// @name         Hide Specific User Comments for Fantasfic
// @namespace    <http://tampermonkey.net/>
// @version      0.6
// @description  Hide comments from a specific user(test). This script was generated with the help of ChatGPT.
// @author       Yo Osanai@<https://www.pixiv.net/users/94571239>
// @match        <https://fantasfic.fun/*>
// @grant        none
// ==/UserScript==

// ==SPECIAL THANKS!!==
// Fantasfic.fun and all those who love creation
// ChatGPT, the Wonderful Friend of Mankind
// ==/SPECIAL THANKS!!==

/*
MIT License

Copyright (c) 2023 Yo Osanai@<https://www.pixiv.net/users/94571239>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

(function() {
    'use strict';

    // ユーザーリスト
    var usersToHide = [
        // ここに非表示にしたいユーザー名のリストを入力してください
        // 「'●●',」のようにユーザー名を''で挟んで、末尾に,をつけてください
        '●●',
    ];
    
    // 非表示にしたいユーザー名が含む文字列のリスト
    // 今登録されてる文字('\\\\',とか)はそのまま推奨
    var stringsToHide = [
        '\\\\',
        'No Name',
        '\\\\n',
        '/n',
        "'",
    ];
    
    // 不適切な内容を含むコメントのリスト
    var inappropriateComments = [
        // ここに非表示にしたい不適切なコメントのリストを入力してください
        // 「'●●',」のようにコメントを''で挟んで、末尾に,をつけてください
	    '××',
	    '△△',
    ];
    // コメントを非表示にする関数
    function hideComments() {
        var comments = document.querySelectorAll('.comment-item, .reply-item');
        comments.forEach(function(comment) {
            var usernameElement = comment.querySelector('.comment-item__user-name, .reply-item__user-name');
            var username = usernameElement.innerText;
            var commentTextElement = comment.querySelector('.comment-item__text, .reply-item__text');
            var commentText = commentTextElement.innerText;
            if (usersToHide.includes(username) || stringsToHide.some(string => username.includes(string)) || inappropriateComments.some(inappropriateComment => commentText.includes(inappropriateComment))) {
                comment.style.display = 'none';
            }
        });
    }

    // 「もっと見る」ボタンにイベントリスナーを追加
    var moreButton = document.querySelector('button.v-btn');
    if (moreButton) {
        moreButton.addEventListener('click', function() {
            // ボタンがクリックされたときにもコメントを非表示にする
            var count = 0;
            var intervalId = setInterval(function() {
                hideComments();
                count++;
                if (count >= 3) {
                    clearInterval(intervalId);
                }
            }, 50);  // 0.05秒ごとに実行
        });
    }

    // 初回実行
    hideComments();

    // 定期的に hideComments() を呼び出す
    setInterval(hideComments, 300);  // 0.3秒ごとに実行
})();