LZTLinkPreview

Add preview overlay to more links in the Zelenka.guru

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         LZTLinkPreview
// @namespace    MeloniuM/LZT
// @version      1.1
// @description  Add preview overlay to more links in the Zelenka.guru
// @author       MeloniuM
// @license      MIT
// @match        http*://zelenka.guru/*
// @match        http*://lolz.live/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    const selectors = [
        '.forum_list .text_Ads',//в рекламе спика раздела
        '.thread_view',//в темах
        '.ImViewContent, .conversationMessages',//в диалогах
        '.profilePage .messageSimpleList',//в профиле
    ];

    function addPreview(elem){
        $(elem).addClass('PreviewTooltip');
        const url = new URL(elem.href);
        $(elem).attr('data-previewurl', url.pathname.slice(1, -1) + '/preview');
        XenForo.PreviewTooltip($(elem));
    }

    $(document).ready(function(){
        if (!$('div#PreviewTooltip').length){
            $('.pageContent').append($('<div id="PreviewTooltip"><div class="previewContent"><span class="PreviewContents">Загрузка...</span></div></div>'));
        }

        $(selectors.join()).find('a[href$="/"]:not(.PreviewTooltip, [href*="?"])').filter('[href^="/threads/"], [href^="https://zelenka.guru/threads/"], [href^="https://lolz.live/threads/"]').each(function(index){
            addPreview(this);
        });
    });

    $(selectors.join()).on('DOMNodeInserted', function(event) {//при добавлении сообщения //.find('a[href^="https://zelenka.guru/threads/"], a[href^="https://lolz.live/threads/]"').filter('a[href$="/"]:not(.PreviewTooltip)')
        $(event.target).find('a[href$="/"]:not(.PreviewTooltip, [href*="?"])').filter('[href^="https://zelenka.guru/threads/"], [href^="https://lolz.live/threads/"]').each(function( index ) {
            if ($(this).closest('.chat2-inputBox, .LolzteamEditorSimple').length) return;
            addPreview(this);
        });
    });
})();