MyDealz Toggle Description

functionality to toggle deal descriptions on mydealz.de

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         MyDealz Toggle Description
// @namespace    http://www.mydealz.de/profile/richi2k
// @version      0.2
// @description  functionality to toggle deal descriptions on mydealz.de 
// @author       richi2k
// @require      https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js
// @match        http://www.mydealz.de/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    
    $(".thread-body div.section-sub:not(:contains('Weiterlesen'))").each(function(){ 
            var dealDescTogglerElement = $('<div class="deal-desc-toggler">Mehr</div>');
            dealDescTogglerElement.addClass("link");

            $(this).css({
                "max-height": $(this).height() + "px",
                "height": "100px",
                "overflow" : "hidden"
            }).addClass("toggled").after(dealDescTogglerElement);
        
    });
    $(document).on("click", ".deal-desc-toggler", function() {
        var dealDescription = $(this).siblings(".thread-body .section-sub");
        
        if(dealDescription.hasClass("toggled")) {
            dealDescription.removeClass("toggled").animate({"height": dealDescription.css("max-height")});
            $(this).text("Weniger");
        } else {
            dealDescription.addClass("toggled").animate({"height": "50px"});
            $(this).text("Mehr");
        }
    });
})();