FloatingHeaders

dodaje obsługę pływających nagłówków do mirko.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         FloatingHeaders
// @namespace    http://tampermonkey.net/
// @version      0.93
// @description  dodaje obsługę pływających nagłówków do mirko.
// @author       @ZasilaczKomputerowy
// @match        https://www.wykop.pl/mikroblog/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    var floatingHeaders = function() {
        var yOffset =  window.pageYOffset+80;

        if(yOffset < 160)
        {
            jQuery('.ellipsis').each(function (e) {
                $(this).removeAttr('style');
            });
            return;
        }
        var mostTopNode = {};
        jQuery('.entry').each(function (e) {
            var top = $(this).offset().top+50;
            if($.isEmptyObject(mostTopNode))
            {
                mostTopNode['node'] = this;
                mostTopNode['top'] = $(this).offset().top+50;
            }
            else
            {
                if(top < yOffset && top > mostTopNode['top'])
                {
                    mostTopNode['node'] = this;
                    mostTopNode['top'] = $(this).offset().top+50;
                }
            }
        });

        var node = mostTopNode['node'];
        var author = $(node).find('.ellipsis').first();
        var width = parseInt($('.entry').last().find('.ellipsis').first().css('width').replace(/px/,'')) + 4 + 'px';

        $(author).css({
            'position': 'fixed',
            'top': '50px',
            'width': width,
            'height': '30px',
            'background-color': 'rgb(44, 44, 44)',
            'opacity': '0.8',
            'z-index': '99999'
        });

        jQuery('.ellipsis').each(function (e) {
            if(this != author.get(0))
            {
                $(this).removeAttr('style');
            }
        });
    };

    $(document).scroll(function(e) {
        floatingHeaders();
    });

    $(document).resize(function(e) {
        floatingHeaders();
    });
})();