LZTHideStickyThreads

Позволяет свернуть список закреплёных тем в разделе

As of 24.06.2023. See ბოლო ვერსია.

// ==UserScript==
// @name         LZTHideStickyThreads
// @namespace    MeloniuM/LZT
// @version      1.0
// @description  Позволяет свернуть список закреплёных тем в разделе
// @author       MeloniuM
// @license MIT
// @match        https://zelenka.guru/forums/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=zelenka.guru
// @require      https://zelenka.guru/js/jquery/jquery-2.1.4.min.js
// @grant        none
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';
    let turn = true;
    let _button = true;
    function start(){
        if (!turn) return;
        if ($('.discussionListItems .stickyThreads .discussionListItem').length != 0){
            if (_button){
                let button, btn_text, span;
                button = $('<a class="button middle hideStickyThreads" style="width: 100%;"><span class="fas fa-chevron-down" style="position: absolute; right: 7px; top: 2px; text-align: center; width: 30px; line-height: 32px;"></span><p></p></a>');
                $('.discussionListItems').prepend(button);
                span = $('.hideStickyThreads span');
                $('.hideStickyThreads p').text((localStorage.getItem('hideStickyThreads') == 'true'? 'Раскрыть закреплённые темы': 'Скрыть закрепленные темы'));
                $(button).on('click', function(e){
                    if ($('.discussionListItems .stickyThreads .discussionListItem').is(':hidden')){
                        $('.hideStickyThreads span').css('transform', 'rotate(180deg)');
                        $('.discussionListItems .stickyThreads .discussionListItem').slideDown('normal');
                        $('.hideStickyThreads p').text('Скрыть закреплённые темы');
                        localStorage.setItem('hideStickyThreads', false)
                    }else{
                        $('.hideStickyThreads span').css('transform', '');
                        $('.discussionListItems .stickyThreads .discussionListItem').slideUp('normal');
                        $('.hideStickyThreads p').text('Раскрыть закреплённые темы');
                        localStorage.setItem('hideStickyThreads', true);
                    }
                });
                _button = false;
            }
            if (localStorage.getItem('hideStickyThreads') == 'false'){
                turn = false;
                return;
            }
            $('.discussionListItems .stickyThreads .discussionListItem').hide();
        }
        requestAnimationFrame(start);
    }
    $('body').on('redy', function(){
        turn = false;
    });
    requestAnimationFrame(start);

})();