Remove Reddtastic Duplicate Posts

Removes duplicate posts

2025-04-11 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला 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         Remove Reddtastic Duplicate Posts
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Removes duplicate posts
// @author       wasivis
// @match        https://*.reddtastic.com/*
// @icon         https://reddtastic.com/favicon.png?v2
// @license      MIT
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    const seenLinks = new Set(); // Keeps track of image and video hyperlinks already encountered

    // Function to hide duplicate posts
    function filterPosts() {
        const posts = document.querySelectorAll('div#posts.mx-safe-2 div.posts__column div.post:not([data-processed="true"])');

        posts.forEach(post => {
            const imageElement = post.querySelector('div a img');
            const videoElement = post.querySelector('div video');
            const imageLink = imageElement ? imageElement.getAttribute('src') : null;
            const videoLink = videoElement ? videoElement.getAttribute('poster') : null;

            // Mark the post as processed to avoid re-checking it
            post.setAttribute('data-processed', 'true');

            // Handle duplicate image and video links
            const uniqueLink = imageLink || videoLink; // Use either image src or video poster
            if (uniqueLink) {
                if (seenLinks.has(uniqueLink)) {
                    post.style.display = 'none'; // Hide duplicate posts
                } else {
                    seenLinks.add(uniqueLink); // Mark this link as seen
                    post.style.display = ''; // Ensure the first occurrence is visible
                }
            }
        });
    }

    // Run the function initially
    filterPosts();

    // Observer for infinite scrolling and dynamically loaded content
    const observer = new MutationObserver(() => {
        filterPosts();
    });

    // Observe changes in the posts container
    const postsContainer = document.querySelector('div#posts.mx-safe-2');
    if (postsContainer) {
        observer.observe(postsContainer, { childList: true, subtree: true });
    }
})();