replace furry

Уточка в диалогах и на странице 404.

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

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

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         replace furry
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Уточка в диалогах и на странице 404.
// @author       Shadman
// @match        https://lolz.live/*
// @match        https://lzt.market/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=lolz.live
// @run-at       document-start
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    const CONVERSATIONS_IMAGE_URL = "https://i.ibb.co/Rphyg3QH/utka-lolz.png";
    const ERROR_404_IMAGE_URL = "https://i.ibb.co/bMvVSTdV/utya-utya-duck.png";
    const style = document.createElement('style');
    style.innerHTML = `
        /* Правило для диалогов */
        img.conversationCapImage {
            content: url("${CONVERSATIONS_IMAGE_URL}") !important;
            object-fit: contain;
        }
        .error-container img {
            content: url("${ERROR_404_IMAGE_URL}") !important;
            object-fit: contain;
            width: 100%; /* На странице ошибки картинка может быть большой */
            max-height: 300px; /* Ограничим высоту, чтобы не была на весь экран */
        }
    `;
    document.head.appendChild(style);
    function replaceSources() {
        const convImg = document.querySelector('img.conversationCapImage');
        if (convImg && convImg.src !== CONVERSATIONS_IMAGE_URL) {
            convImg.src = CONVERSATIONS_IMAGE_URL;
        }
        const errorImg = document.querySelector('.error-container img');
        if (errorImg && errorImg.src !== ERROR_404_IMAGE_URL) {
            errorImg.src = ERROR_404_IMAGE_URL;
            errorImg.removeAttribute('width');
            errorImg.removeAttribute('height');
        }
    }

    const observer = new MutationObserver((mutations) => {
        replaceSources();
    });

    observer.observe(document.documentElement, {
        childList: true,
        subtree: true
    });

    replaceSources();
})();