Reddit Repeating Post Filter

Reddit has a bug where the same post can reappear multiple times while scrolling. This script removes those duplicates

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Reddit Repeating Post Filter
// @description  Reddit has a bug where the same post can reappear multiple times while scrolling. This script removes those duplicates
// @match        https://www.reddit.com/*
// @version      0.1
// @author       mica
// @namespace    greasyfork.org/users/12559
// @license      MIT
// ==/UserScript==

let a = [];
const observer = new MutationObserver(() => {
    if (location.pathname.match(/\/r\/[\w\d]*\/$/) || location.search.includes('?feed')) {
        document.querySelectorAll('a[slot=full-post-link]:not(.checked)').forEach(e => {
            if (a.some(url => e.href.match(url))) {
                e.closest('article').remove();
            } else {
                e.classList.add('checked');
            }
            a.push(e.href);
        })
    }
});
observer.observe(document.body, {
    childList: true,
    subtree: true
});