LZTToggleRead

Mark conversation as unread

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         LZTToggleRead
// @namespace    MeloniuM/LZT
// @version      1.1
// @description  Mark conversation as unread
// @author       MeloniuM
// @match        https://lolz.live/conversations/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=lolz.live
// @grant        none
// ==/UserScript==
(function () {
    'use strict';
    $(document).bind('PopupMenuShow', function (e) {
        let $menu = e.$menu;
        let $context = $menu.data('XenForo.PopupMenu').$container;
        // Исключаем лишние контексты
        if ($context.is('.RecipientsPopup') || !$context.closest('.membersAndActions').length) return;
        // Не добавляем кнопку, если она уже есть
        if ($menu.find('.conversationToggleRead').length) return;
        // Добавляем кнопку "Пометить как непрочитанное"
        $menu.find(".secondaryContent, .blockLinksList").append(`
     <a class="item control conversationToggleRead MenuCloser">
    <span class="Svg-Icon">
        <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" stroke-width="2" stroke="currentColor" viewBox="0 0 24 24">
            <path stroke-linecap="round" stroke-linejoin="round" d="M3 8l9 6 9-6M3 8v8a2 2 0 002 2h14a2 2 0 002-2V8M3 8l9 6 9-6" />
        </svg>
    </span>
    Пометить как не прочитанное
</a>`).xfActivate();
    });
    $(document).on('click', '.conversationToggleRead', function (e) {
        e.preventDefault();
        let conversationId = Im.conversationId;
        $('#Conversations').data('Im.Start').goToConversationList();
        XenForo.ajax(`/conversations/${conversationId}/toggle-read`, {
            _xfConfirm: 1
        }, function (response) {
            if (response && !response.error) {
                $(`#conversation-${conversationId}`).addClass('unread');
            }
        });
    });
})();