Minimize pics

Minimize pics/youtube/wikipedia/tweet previews in chat

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==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 });

})();