VK Image Blur for Specific Users

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

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         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 });

})();