Загрузка...

Layout Make reviews collapsible (and preferably remember this state in the browser)

Thread in Suggestions created by achies Mar 23, 2024. (bumped Mar 29, 2024) 228 views

The poll
Согласны ли вы с предложением?
  1. Да

    100%
    12
  2. Да, но нужно доработать (опишу в комментариях)

    0%
    0
  3. Нет

    0%
    0
  1. achies
    Смотрите какой большой разрыв сейчас при скролле между категориями и аккаунтами из-за блока отзывов
    [IMG]
    Предлагаю добавить кнопку свернуть/развернуть как спойлер и запоминать это состояние в localstorage. Это существенно уменьшает разрыв


    [IMG]
    Вот накидал скрипт с простенькой реализацией в тампере


    JS
    // ==UserScript==
    // @name Reviews spoiler
    // @namespace http://tampermonkey.net/
    // @version 2024-03-23
    // @description try to take over the world!
    // @author You
    // @match https://lzt.market/user/items*
    // @match https://lzt.market/*
    // @icon https://www.google.com/s2/favicons?sz=64&domain=lzt.market
    // @grant none
    // ==/UserScript==

    const reviewHeader = document.querySelector(".list-tab_reviews");
    const feedbackList = document.getElementById("feedbackList");
    const toggleButton = document.createElement("button");
    const savedStyle = localStorage.getItem('savedReviewStyle') || "none";
    toggleButton.textContent = savedStyle !== "none" ? "Свернуть" : "Развернуть";
    feedbackList.style.display = savedStyle;
    reviewHeader.style.display = 'flex';
    reviewHeader.style.alignItems = 'center';
    toggleButton.className += "element button smallButton ExpandParams HoldTooltip"
    toggleButton.onclick = function () {
    const newValue = feedbackList.style.display === "none" ? "block" : "none";
    feedbackList.style.display = newValue;
    localStorage.setItem('savedReviewStyle', newValue);
    toggleButton.textContent =
    newValue === "none" ? "Развернуть" : "Свернуть";
    };

    reviewHeader.appendChild(toggleButton);
     
    1. View previous comments (1)
    2. achies Topic starter
      жди, вхахаха. Щас верну
    3. Karma
    4. View the next comments (3)
  2. < >
    M1ch4elx
    Допилил локальное сохранение последнего выбранного параметра

    JS
    // ==UserScript==
    // @name Reviews spoiler
    // @namespace [URL]http://tampermonkey.net/[/URL]
    // @version 2024-03-23
    // @description try to take over the world!
    // @author You
    // @match [URL]https://lzt.market/user/items*[/URL]
    // @match [URL]https://lzt.market/*[/URL]
    // @icon [URL]https://www.google.com/s2/favicons?sz=64&domain=lzt.market[/URL]
    // @grant none
    // ==/UserScript==

    const reviewHeader = document.querySelector(".list-tab_reviews");
    const feedbackList = document.getElementById("feedbackList");
    const toggleButton = document.createElement("button");
    const savedStyle = localStorage.getItem('savedReviewStyle') || "none";
    toggleButton.textContent = savedStyle !== "none" ? "Свернуть" : "Развернуть";
    feedbackList.style.display = savedStyle;
    reviewHeader.style.display = 'flex';
    reviewHeader.style.alignItems = 'center';
    toggleButton.className += "element button smallButton ExpandParams HoldTooltip"
    toggleButton.onclick = function () {
    const newValue = feedbackList.style.display === "none" ? "block" : "none";
    feedbackList.style.display = newValue;
    localStorage.setItem('savedReviewStyle', newValue);
    toggleButton.textContent =
    newValue === "none" ? "Развернуть" : "Свернуть";
    };

    reviewHeader.appendChild(toggleButton);
     
    1. View previous comments (1)
    2. < >
      M1ch4elx
      achies, Я думал ты к себе закинешь, ну давай открою
    3. achies Topic starter
      M1ch4elx, ты прав, закинул в шапку. Щас такими темпами лолз перепишем
    4. < >
Top
Loading...