Minimize pics

Minimize pics/youtube/wikipedia/tweet previews in chat

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

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

})();