Greasy Fork

Greasy Fork is available in English.

LZTHideStickyThreads

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

当前为 2024-07-26 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

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

(function() {
    'use strict';
    let enabled = localStorage.getItem('hideStickyThreads');
    function check(){
        let loc = window.location.pathname;
        if (loc.startsWith('/forums/766/') || loc.startsWith('/forums/contests/')){
            requestAnimationFrame(check);
            return;
        }
        if ($('.discussionListItems .stickyThreads .discussionListItem').length != 0){
            if ($('.button.hideStickyThreads').length == 0){
                addButton(enabled);
            }
            if (enabled == 'true'){
                $('.discussionListItems .stickyThreads .discussionListItem:visible').hide();
            }
        }
        requestAnimationFrame(check);
    }
    function addButton(){
        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((enabled == 'true'? 'Раскрыть закреплённые темы': 'Скрыть закрепленные темы'));
        span.css('transform', (enabled == 'true'? '':'rotate(180deg)'));
        $(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);
                enabled = 'false';
            }else{
                $('.hideStickyThreads span').css('transform', '');
                $('.discussionListItems .stickyThreads .discussionListItem').slideUp('normal');
                $('.hideStickyThreads p').text('Раскрыть закреплённые темы');
                localStorage.setItem('hideStickyThreads', true);
                enabled = 'true';
            }
        });
    }
    requestAnimationFrame(check);

})();