From bdf9aea1ce4c1eec607220a93e41c810b5204aa0 Mon Sep 17 00:00:00 2001 From: Andreas Jansson Date: Thu, 12 Sep 2024 12:06:34 +0200 Subject: [PATCH] keyword filter for crypto etc --- lib/content.js | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/lib/content.js b/lib/content.js index cadfaeb..aa52e29 100644 --- a/lib/content.js +++ b/lib/content.js @@ -209,15 +209,35 @@ export async function getContent( return []; } - const filteredPosts = posts.filter( - (post) => post.username && post.username.trim() !== "" - ); + const filteredPosts = posts.filter(filterPost); filteredPosts.sort(customPostSort); return filteredPosts; } +function filterPost(post) { + const username = post.username; + const name = post.name.toLowerCase(); + const description = post.description ? post.description.toLowerCase() : ""; + if (!username || username.trim() == "") { + return false; + } + const bannedStrings = ["nft", "crypto", "telegram", "clicker", "solana", "stealer"]; + + for (var s of bannedStrings) { + if (name.includes(s) || description.includes(s)) { + return false; + } + } + + if (name.includes("stake") && name.includes("predict")) { + return false; + } + + return true; +} + function customPostSort(p1, p2) { const key = (p) => p.source == "reddit"