BGM.TV Image Replacer

Replace specific image on bgm.tv pages

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         BGM.TV Image Replacer
// @namespace    https://bgm.tv
// @version      1.0
// @description  Replace specific image on bgm.tv pages
// @author       Rin
// @match        https://bgm.tv/group/topic/*
// @grant        none
// @license MIT
// ==/UserScript==
(function() {
    'use strict';
    window.addEventListener('load', function() {
        if (window.location.href.includes("bgm.tv/group/topic/")) {
            var images = document.querySelectorAll('img');
            images.forEach(function(image) {
                if (image.src.includes("/img/smiles/tv/102.gif")) {
                    image.src = image.src.replace("/img/smiles/tv/102.gif", "/img/smiles/tv/40.gif");
                }
            });
            var elementsWithBg = document.querySelectorAll('[style*=background-image]');
            elementsWithBg.forEach(function(element) {
                var style = window.getComputedStyle(element);
                var backgroundImage = style.backgroundImage;
                if (backgroundImage.includes("/img/smiles/tv/102.gif")) {
                    element.style.backgroundImage = backgroundImage.replace("/img/smiles/tv/102.gif", "/img/smiles/tv/40.gif");
                }
            });
        }
    });
})();