Humoruniv Block User Script

Blocks posts and comments from specific users on humoruniv.com

21.06.2024 itibariyledir. En son verisyonu görün.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         Humoruniv Block User Script
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  Blocks posts and comments from specific users on humoruniv.com
// @author       ChatGPT
// @match        https://m.humoruniv.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // 블라인드 리스트 관리 GUI 생성
    let blindList = JSON.parse(localStorage.getItem('blindList') || '[]');

    function saveBlindList() {
        localStorage.setItem('blindList', JSON.stringify(blindList));
    }

    function addUserToBlindList(nickname) {
        if (nickname && !blindList.some(user => user.nickname === nickname)) {
            blindList.push({ nickname: nickname, date: new Date().toLocaleString('ko-KR', { hour12: false }) });
            saveBlindList();
            renderBlindList();
            hidePosts();
            hideComments();
        }
    }

    function removeUserFromBlindList(nickname) {
        blindList = blindList.filter(user => user.nickname !== nickname);
        saveBlindList();
        renderBlindList();
    }

    function renderBlindList() {
        const listElement = document.getElementById('blindList');
        listElement.innerHTML = '';

        blindList.forEach(user => {
            const listItem = document.createElement('li');
            listItem.textContent = `${user.nickname} (${user.date})`;
            const removeButton = document.createElement('button');
            removeButton.textContent = '삭제';
            removeButton.onclick = () => removeUserFromBlindList(user.nickname);
            listItem.appendChild(removeButton);
            listElement.appendChild(listItem);
        });
    }

    function saveGuiState(isHidden) {
        localStorage.setItem('guiHidden', isHidden);
    }

    function loadGuiState() {
        return localStorage.getItem('guiHidden') === 'true';
    }

    // GUI 생성
    const gui = document.createElement('div');
    gui.style.position = 'fixed';
    gui.style.bottom = '10px';
    gui.style.right = '10px';
    gui.style.backgroundColor = 'white';
    gui.style.border = '1px solid black';
    gui.style.padding = '10px';
    gui.style.zIndex = 10000;

    const title = document.createElement('h3');
    title.textContent = '블라인드 리스트';
    gui.appendChild(title);

    const list = document.createElement('ul');
    list.id = 'blindList';
    gui.appendChild(list);

    const inputField = document.createElement('input');
    inputField.type = 'text';
    inputField.placeholder = '닉네임 추가';
    gui.appendChild(inputField);

    const addButton = document.createElement('button');
    addButton.textContent = '추가';
    addButton.onclick = () => {
        addUserToBlindList(inputField.value.trim());
        inputField.value = '';
    };
    gui.appendChild(addButton);

    const hideButton = document.createElement('button');
    hideButton.textContent = '숨기기';
    hideButton.onclick = () => {
        gui.style.display = 'none';
        showButton.style.display = 'block';
        saveGuiState(true);
    };
    gui.appendChild(hideButton);

    document.body.appendChild(gui);

    const showButton = document.createElement('button');
    showButton.textContent = '블라인드';
    showButton.style.position = 'fixed';
    showButton.style.bottom = '10px';
    showButton.style.right = '10px';
    showButton.style.zIndex = 10000;
    showButton.style.display = 'none';
    showButton.onclick = () => {
        gui.style.display = 'block';
        showButton.style.display = 'none';
        saveGuiState(false);
    };
    document.body.appendChild(showButton);

    if (loadGuiState()) {
        gui.style.display = 'none';
        showButton.style.display = 'block';
    } else {
        gui.style.display = 'block';
        showButton.style.display = 'none';
    }

    renderBlindList();

    // 게시글 가리기
    function hidePosts() {
        if (location.href.includes('list.html') && !location.href.includes('st=name')) {
            document.querySelectorAll('#list_body > ul > a').forEach(post => {
                const nickname = post.querySelector('#list_body > ul > a > li > table > tbody > tr > td:nth-child(2) > div > span.nick').textContent;
                if (blindList.some(user => user.nickname === nickname)) {
                    post.style.display = 'none';
                }
            });

            document.querySelectorAll('#list_best_normal > ul > a').forEach(post => {
                const nickname = post.querySelector('#list_best_normal > ul > a > li > table > tbody > tr > td > div:nth-child(3)').textContent;
                if (blindList.some(user => user.nickname === nickname)) {
                    post.style.display = 'none';
                }
            });
        }
    }

    // 댓글 가리기
    function hideComments() {
        if (location.href.includes('read.html')) {
            document.querySelectorAll('li').forEach(comment => {
                const nickname = comment.querySelector('span.nick')?.textContent;

                if (nickname && blindList.some(user => user.nickname === nickname)) {
                    if (comment.className.includes('sub_comm_bt')) {
                        comment.style.display = 'none';
                    } else if (comment.className.includes('best_li') || comment.id.includes('comment_li')) {
                        let nextElement = comment.nextElementSibling;
                        while (nextElement && nextElement.className.includes('sub_comm_bt')) {
                            nextElement.style.display = 'none';
                            nextElement = nextElement.nextElementSibling;
                        }
                        comment.style.display = 'none';
                    }
                }
            });
        }
    }

    hidePosts();
    hideComments();
})();