LZTToggleRead

Mark conversation as unread

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