Black List

скрывает комментарии юзера

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(У мене вже є менеджер скриптів, дайте мені встановити його!)

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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Black List
// @namespace    http://shikimori.io
// @description  скрывает комментарии юзера
// @version      1.2
// @author       pirate-
// @match        *://shikimori.io/*
// @match        *://shikimori.rip/*
// @match        *://shiki.one/*
// @grant        none
// ==/UserScript==

(function() {
	'use strict';

	let hiddenUserIds = [];

	if (localStorage.getItem('hiddenUserIds')) {
		hiddenUserIds = JSON.parse(localStorage.getItem('hiddenUserIds'));
	}

	function updateBlacklistStyle(userIds) {
		let styleElement = document.getElementById('blacklist');

		if (!styleElement) {
			styleElement = document.createElement('style');
			styleElement.id = 'blacklist';
			document.head.appendChild(styleElement);
		}

		const newRule = userIds.map(id => `.b-comment[data-user_id="${id}"]`).join(', ') + ' { display: none; }';
		styleElement.innerHTML = newRule;

		updateBlockedUsersList(userIds);
	}

	function updateBlockedUsersList(userIds) {
		blockedUsersList.innerHTML = '';

		userIds.forEach(userId => {
			const commentElement = document.querySelector(`.b-comment[data-user_id="${userId}"]`);
			if (commentElement) {
				const nickname = commentElement.getAttribute('data-user_nickname');

				const userBlock = document.createElement('div');
				const nicknameLink = document.createElement('a');
				nicknameLink.href = `https://shikimori.one/${nickname}`;
				nicknameLink.textContent = nickname;

				const unblockButton = document.createElement('span');
				unblockButton.textContent = '×';
				unblockButton.style.color = 'red';
				unblockButton.style.cursor = 'pointer';

				unblockButton.addEventListener('click', () => {
					const index = hiddenUserIds.indexOf(userId);
					if (index > -1) {
						hiddenUserIds.splice(index, 1);
						localStorage.setItem('hiddenUserIds', JSON.stringify(hiddenUserIds));
						updateBlacklistStyle(hiddenUserIds);
						updateBlockedUsersList(hiddenUserIds);
					}
				});

				userBlock.appendChild(nicknameLink);
				userBlock.appendChild(unblockButton);
				blockedUsersList.appendChild(userBlock);
			}
		});
	}

	function addBlockText(mainControls) {
		const commentElement = mainControls.closest('.b-comment');
		const userId = commentElement.getAttribute('data-user_id');

		if (!hiddenUserIds.includes(userId) && !mainControls.querySelector('.block-text')) {
			const blockText = document.createElement('span');
			blockText.classList.add('block-text');
			blockText.style.cursor = 'pointer';
			blockText.style.color = 'red';
			blockText.addEventListener('click', function() {
				if (!hiddenUserIds.includes(userId)) {
					hiddenUserIds.push(userId);
					localStorage.setItem('hiddenUserIds', JSON.stringify(hiddenUserIds));
					updateBlacklistStyle(hiddenUserIds);
				}
			});

			mainControls.appendChild(blockText);
		}
	}

	function updateComments() {
		const mainControlsList = document.querySelectorAll('.b-comment .inner .buttons .main-controls');
		mainControlsList.forEach(addBlockText);
	}

	const blockedUsersList = document.createElement('div');
	blockedUsersList.className = 'blist-users';
	blockedUsersList.style.display = 'none';

	function createShowBlockedButton() {
		const showBlockedButton = document.createElement('span');
		showBlockedButton.classList.add('show-blist', 'b-button');
		showBlockedButton.textContent = 'список';
		showBlockedButton.style.cursor = 'pointer';

		showBlockedButton.addEventListener('click', () => {
			showBlockedButton.classList.toggle('active');
			blockedUsersList.style.display = blockedUsersList.style.display === 'none' ? 'flex' : 'none';
			updateBlockedUsersList(hiddenUserIds);
		});

		return showBlockedButton;
	}

	function initInterface() {
		document.body.appendChild(createShowBlockedButton());
		document.body.appendChild(blockedUsersList);
	}

	const styles = document.createElement('style');
	styles.innerHTML = `
    .blist-users {
        gap: 5px;
        flex-direction: column;
        max-height: 100px;
        overflow-y: auto;
        position: fixed;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        z-index: 99;
        background: white;
        width: 300px;
        border-radius: 3px;
        box-shadow: 0 1px 2px 0 rgba(0, 0, 0, .16);
        padding: 10px;
    }

    .blist-users > div {
        display: flex;
        justify-content: space-between;
    }

    .show-blist {
        position: fixed;
        right: 5px;
        top: 70px;
    }

   .block-text {
   opacity:.7;
   margin-left: 15px;
}

   .block-text:hover {
    opacity:1;
}

    .block-text:before {
    font-family: shikimori;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-font-feature-settings: 'liga';
    font-feature-settings: 'liga';
    text-transform: none;
    letter-spacing: normal;
    content: "";
    }

    `;
	document.head.appendChild(styles);

	function checkElementsPeriodically() {
		updateComments();
		if (!document.querySelector('.show-blist')) {
			initInterface();
		}
	}

	setInterval(checkElementsPeriodically, 1000);
	updateBlacklistStyle(hiddenUserIds);
})();