VK Image Blur for Specific Users

Blurs images from specific users in VK conversations and removes blur on hover

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         VK Image Blur for Specific Users
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  Blurs images from specific users in VK conversations and removes blur on hover
// @author       antowkas
// @match        https://vk.com/im*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Задайте список имен пользователей, чьи изображения нужно размыть
    const targetNames = ["Дима Михайлов", "ミリフ 遺構"];

    function blurImagesForUsers() {
        // Находим все сообщения в истории беседы
        const messages = document.querySelectorAll('.ConvoHistory__dateStack section');

        messages.forEach(message => {
            // Находим имя отправителя сообщения
            const authorElement = message.querySelector('.ConvoMessageHeader__authorLink .PeerTitle__title');
            if (authorElement && targetNames.includes(authorElement.textContent.trim())) {
                // Находим все изображения в сообщении и применяем к ним blur
                const images = message.querySelectorAll('img.PhotoItem__img, img.ReImage__img');
                images.forEach(img => {
                    img.style.filter = 'blur(10px)'; // Применяем размытие

                    // Добавляем обработчики событий для наведения и ухода курсора
                    img.addEventListener('mouseenter', () => {
                        img.style.filter = 'none'; // Убираем размытие при наведении
                    });

                    img.addEventListener('mouseleave', () => {
                        img.style.filter = 'blur(10px)'; // Возвращаем размытие при уходе курсора
                    });
                });
            }
        });
    }

    // Выполняем функцию сразу после загрузки страницы
    window.addEventListener('load', blurImagesForUsers);

    // Также добавляем наблюдатель за изменениями в DOM, чтобы обрабатывать новые сообщения
    const observer = new MutationObserver(blurImagesForUsers);
    observer.observe(document.body, { childList: true, subtree: true });

})();