Filter topics

Hide topics without new messages

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         Filter topics
// @license      MIT
// @namespace    http://websight.blue
// @version      1.01
// @description  Hide topics without new messages
// @author       Milan
// @match        *://*.websight.blue/threads/*
// @match        *://websight.blue
// @icon         https://lore.delivery/static/blueshi.png
// ==/UserScript==

const hideTopics = button => {
    button.innerText = "Unfilter topics";
    document.querySelectorAll("#thread-list>tbody>tr").forEach( row => {
        if(!!row.id && !!row.querySelector(".thread-unread").style.display) { row.style.display = "none"; }
    });
}

const showTopics = button => {
    button.innerText = "Filter topics";
    document.querySelectorAll("#thread-list>tbody>tr").forEach( row => {
        row.style.display = "table-row";
    });
}

let filtered = JSON.parse(localStorage.getItem("filterlock")) || false;

const placeButton = menu => {
    const button = document.createElement("a");
    button.href = "#";
    button.id = "GM-filter-button";
    button.title = "Only show updated topics";
    button.innerText = "Filter topics";
    button.addEventListener('click', () => {
        if (filtered) {
            showTopics(button);
            filtered = false;
        }
        else {
            hideTopics(button);
            filtered = true;
        }
    });

    button.addEventListener('dblclick', () => {
        if(JSON.parse(localStorage.getItem("filterlock"))) {
            localStorage.setItem("filterlock", "false");
            showTopics(button);
            menu.lastChild.remove();
        }
        else {
            localStorage.setItem("filterlock", "true");
            hideTopics(button);
            menu.append(" 🔒");
        }
    });
    menu.append(" | ");
    menu.append(button);
    if (JSON.parse(localStorage.getItem("filterlock"))) { menu.append(" 🔒"); }
    document.addEventListener('keydown', function(e) {
        if (e.key == 'o') {
            button.click();
        }
    });
}

(() => {
    'use strict';
    const buttonLocation = document.querySelector(".userbar");
    placeButton(buttonLocation);
    if (JSON.parse(localStorage.getItem("filterlock"))) {
        hideTopics(document.getElementById("GM-filter-button"));
        filtered = true;
    }
})();