Reddit Deduplicator

Deduplicates posts in reddit.com/r/friends

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Reddit Deduplicator
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Deduplicates posts in reddit.com/r/friends
// @author       Marquita
// @match        https://www.reddit.com/r/friends/
// @icon         https://www.google.com/s2/favicons?domain=reddit.com
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    const table = document.getElementById("siteTable");

    function checkVisibility(elem) {
        const url = elem.dataset.url
        console.log(url)
        const stored = uniques.get(url)
        switch(stored) {
           case undefined:
               uniques.set(url, elem)
           case elem: // eslint-disable-line no-fallthrough
               return true
           default:
               return false
        }
    }

    function dedupe(elem) {
        var unique = checkVisibility(elem)
        if(!unique) {
            elem.style.display = "none";
        };
        return unique
    }

    function callback() {
        table.querySelectorAll("div#siteTable div.thing").forEach(dedupe)
    }

    const observer = new MutationObserver(callback);
    observer.observe(table, { childList: true });

    var uniques = new Map();
    callback();
})();