Minimize pics

Minimize pics/youtube/wikipedia/tweet previews in chat

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         Minimize pics
// @description  Minimize pics/youtube/wikipedia/tweet previews in chat
// @version      0.1
// @author       lois6b
// @include      *chat.stackexchange.com/rooms/*
// @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js
// @namespace https://greasyfork.org/users/241254
// ==/UserScript==

(function() {
var img = "https://cdn3.iconfinder.com/data/icons/google-material-design-icons/48/ic_keyboard_arrow_right_48px-128.png";

    jQuery("head").append("<style>\
.rotated{\
-webkit-transform : rotate(90deg);\
-moz-transform: rotate(90deg);\
transform: rotate(90deg);\
}\</style>");


    function tratar(){
        $('.ob-image, .ob-tweet, .ob-wikipedia, .ob-youtube ').each(function(){
            var content =  $(this).parent();
            if(content.children().length == 1){
                content.prepend('<img class="minim rotated" width="20px" heigth="20px" src="'+img+'">')
                content.find('.minim').click(function(){
                    $(this).parent().find('div[class*=ob]').slideToggle()
                    $(this).hasClass('rotated')? $(this).removeClass('rotated'): $(this).addClass('rotated');})
            }
        });
    }


    let mirador = new MutationObserver(async (records, _) => {
        tratar();
    })
    mirador.observe($('#chat')[0], { childList: true, subtree: true });

})();