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 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

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