Filter topics

Hide topics without new messages

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

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