diff --git a/lib/routes/4chan/catalog.tsx b/lib/routes/4chan/catalog.tsx
new file mode 100644
index 000000000..ba04087e7
--- /dev/null
+++ b/lib/routes/4chan/catalog.tsx
@@ -0,0 +1,51 @@
+import type { Context } from 'hono';
+
+import type { Route } from '@/types';
+import got from '@/utils/got';
+
+import type { CatalogApiReturn } from './utils';
+import { parseParams, processCatalog } from './utils';
+
+const handler = async (ctx: Context) => {
+ const { board } = ctx.req.param();
+ const viewOptions = parseParams(ctx.req.param('routeParams'));
+ const { data }: { data: CatalogApiReturn } = await got(`https://a.4cdn.org/${board}/catalog.json`);
+
+ return {
+ title: `4chan's /${board}/`,
+ link: `https://boards.4chan.org/${board}/catalog`,
+ item: processCatalog({ data, board, viewOptions }),
+ };
+};
+
+export const route: Route = {
+ path: '/:board/catalog/:routeParams?',
+ categories: ['bbs'],
+ example: '/4chan/g/catalog',
+ parameters: {
+ board: '4chan board',
+ routeParams: 'extra parameters, see the table above',
+ },
+ features: {
+ requirePuppeteer: false,
+ antiCrawler: false,
+ supportBT: false,
+ supportPodcast: false,
+ supportScihub: false,
+ },
+ name: "Board's catalog",
+ maintainers: ['heisenshark'],
+ radar: [
+ {
+ source: ['boards.4chan.org/:board/'],
+ target: '/:board/catalog',
+ },
+ ],
+ description: `Specify options (in the format of query string) in parameter \`routeParams\` to control some extra features for Tweets
+| Key | Description | Accepts | Defaults to |
+| ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------ | ---------------------- | ----------------------------------------- |
+| \`showReplyCount\` | Show number of replies of each thread in catalog | \`0\`/\`1\`/\`true\`/\`false\` | \`false\` |
+| \`showLastReplies\` | Show last 5 replies of each thread | \`0\`/\`1\`/\`true\`/\`false\` | \`false\` |
+| \`revealSpoilers\` | Don't wrap images tagged as spoilers | \`0\`/\`1\`/\`true\`/\`false\` | \`false\` |`,
+ handler,
+};
diff --git a/lib/routes/4chan/namespace.ts b/lib/routes/4chan/namespace.ts
new file mode 100644
index 000000000..1c7e8172e
--- /dev/null
+++ b/lib/routes/4chan/namespace.ts
@@ -0,0 +1,9 @@
+import type { Namespace } from '@/types';
+
+export const namespace: Namespace = {
+ name: '4chan',
+ url: '4chan.org',
+ categories: ['bbs'],
+ lang: 'en',
+ description: '',
+};
diff --git a/lib/routes/4chan/utils.tsx b/lib/routes/4chan/utils.tsx
new file mode 100644
index 000000000..bc5b3631d
--- /dev/null
+++ b/lib/routes/4chan/utils.tsx
@@ -0,0 +1,124 @@
+import { raw } from 'hono/html';
+import { renderToString } from 'hono/jsx/dom/server';
+import sanitizeHtml from 'sanitize-html';
+
+import { parseDate } from '@/utils/parse-date';
+import { queryToBoolean } from '@/utils/readable-social';
+
+const parseParams = (routeParams: string) => {
+ const parsed = new URLSearchParams(routeParams);
+ const viewOptions = {
+ includeLastReplies: !!queryToBoolean(parsed.get('showLastReplies')),
+ includeReplyCount: !!queryToBoolean(parsed.get('showReplyCount')),
+ revealSpoilers: !!queryToBoolean(parsed.get('revealSpoilers')),
+ };
+ return viewOptions;
+};
+
+const processCatalog = ({ data, board, viewOptions }: { data: CatalogApiReturn; board: string; viewOptions: ViewOptions }) => {
+ const transformedData = data.flatMap((page) => page.threads);
+ return transformedData.map((thread) => ({
+ author: `${thread.name} ${thread.trip ?? thread.no}`,
+ description: renderToString(renderPost({ post: thread, board, viewOptions })),
+ link: `https://boards.4chan.org/${board}/thread/${thread.no}`,
+ pubDate: parseDate(thread.time * 1000),
+ title: thread.sub ?? sanitizeHtml(thread.com?.split('
')[0] ?? '', { allowedTags: [] }),
+ }));
+};
+
+const renderPost = ({ post, board, viewOptions }: { post: ChanPost; board: string; viewOptions: ViewOptions }) => {
+ let media = <>>;
+ switch (post.ext) {
+ case '.jpg':
+ case '.png':
+ case '.gif':
+ media = ;
+ break;
+ case '.pdf':
+ media = ;
+ break;
+ case '.swf':
+ media = ;
+ break;
+ case '.webm':
+ media = ;
+ break;
+ default:
+ break;
+ }
+ if (post.spoiler) {
+ media = (
+
Spoiler
+ {media}
+
{media}
+ >
+ );
+ const renderedPost = (
+ <>
+ {post.last_replies && viewOptions.includeReplyCount && (
+ <>
+ {post.replies} 💬
+
+ >
+ )}
+ {raw(post.com ?? '')}
+ {media}
+ {viewOptions.includeLastReplies && post.last_replies?.map((n) =>