LZTToggleRead

Mark conversation as unread

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         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');
            }
        });
    });
})();