Filter 1pbtID on 4chan /pol/

Filter 1pbtID on /pol/ and /biz/ (Requires 4chanX Catalog)

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name Filter 1pbtID on 4chan /pol/
// @namespace Violentmonkey Scripts
// @match https://boards.4chan.org/*
// @match https://boards.4channel.org/*
// @grant none
// @license MIT
// @version 1.0
// @run-at document-start
// @author Anons on /g/ https://desuarchive.org/g/thread/85972536/
// @description Filter 1pbtID on /pol/ and /biz/ (Requires 4chanX Catalog)
// ==/UserScript==

const postlimit = 20; // if 1pbtid and replies > postlimit, filtered

const shiftclick = new MouseEvent("click", {
 shiftKey: true,
 bubbles: true,
 cancelable: true,
 view: window
});

const filterThread = elem => elem.dispatchEvent(shiftclick);

const startup = async () => {
 const m = location.href.match(/https:\/\/boards\.4chan(?:nel)?\.org\/(.*)\//);
 if (!m) return;
 const board = m[1];
 if (!['pol', 'biz'].includes(board)) return;
 const isCatalog = !!document.querySelector('.catalog-small');
 if (!isCatalog) return;
if (document.getElementById('hidden-toggle').innerText == "[Hide]") return;
 const getThread = async pnum => await (await fetch(`https://a.4cdn.org/${board}/thread/${pnum}.json`)).json();
 await Promise.all([...document.querySelectorAll('.thread.catalog-thread')].map(async e => {
 const {posts} = await getThread(e.id.substr(1));
 const opid = posts[0].id;
 const pbtid = posts.filter(e => e.id == opid).length;
 if (pbtid != 1)
 return;
 if (posts.length < postlimit)
 return;
 console.log(`Filtering >>${e.id.substr(1)}`);
 filterThread(e);
 }));
 console.log('Processing finished');
};

document.addEventListener('IndexRefresh', () => startup());