// Notes: // Catty wipe code for (the highly unlikely event) that we are raided with CP or Loli // this was modified from gigacha.de's vichan version to prevent spam from the notorious russian commercial CP spammer // i have removed links to catbox.moe within the whitelist as they may contain loli or actual CP // you shouldn't worry much about this as servimg does the MPA work for // go to https://soyblog.forumotion.com/13986.js for the java only version of this code // try to gatekeep the link just incase, currently it is only findable through scraping the site for sub-domains checkPostShorteners: async (options) => {} const { proxy } = config.get; const blacklistedKeywords = config.get.blacklistedKeywords || [ "previews", "202X", "cp", "child porn", "loli", "cunny", "p'", "o'", "CSAM", "DNB", "Dead Nigger Baby", "child gore", "foodist", "UTTP", "pedophile", "pedo", "skibidi farms", "764", "IP", "soycord", "discord", "epstein", "jassy", "peter scully", ]; const allowedDomains = config.get.allowedDomains || [ "voca.ro", "vocaroo.com", "xcancel.com", "x.com", "twitter.com", "youtube.com", "m.youtube.com", "music.youtube.com", "youtu.be", "garticphone.com", "skribbl.io", "archive.ph", "archive.org", "web.archive.org", "4chan.org", "boards.4chan.org", "wikipedia.org", "strawpoll.com", "soyjak.st", "soyjakwiki.org", "gigacha.de", "wiki.gigacha.de", "github.com", "gitlab.com", "sncapedia.org", "swedishwin.com", ]; const post = await; Posts.getPost( options.board._id || options.board, options.postId, true ); const siteLinks = post.nomarkup.match( /\b(?:https?:\/\/|www\.)[^\s<>"']+/gi ); if (!siteLinks?.length) return; const filteredLinks = siteLinks.filter((url) => { try { const parsed = new URL( url.startsWith("http") ? url : `http://${url}` ); const host = parsed.hostname .replace(/^www\./, "") .toLowerCase(); return !allowedDomains.some( (d) => host === d || host.endsWith(`.${d}`) ); } catch { return false; } }); const uniqueLinks = [...new Set(filteredLinks)].slice(0, 10); console.log("Found links:", uniqueLinks); const agent = proxy.enabled ? new SocksProxyAgent(require("url").parse(proxy.address)) : null; const resolveSite = async (url, signal) => { let currentUrl = url; for (let i = 0; i <= maxRedirects; i++) { const res = await fetch(currentUrl, { timeout: 10000, agent, redirect: "manual", signal, headers: { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:146.0) Gecko/20100101 Firefox/146.0", }, }); if (res.status >= 300 && res.status < 400) { const location = res.headers.get("location"); currentUrl = new URL(location, currentUrl).toString(); continue; } if (i === 0) { // site wasn't a redirect return null; } return res; } return null; }; const scanShortener = async (url) => { try { const controller = new AbortController(); setTimeout(() => controller.abort(), 10000); const res = await resolveSite(url, controller.signal); if (!res) return false; const text = await res.text(); return blacklistedKeywords.some((k) => text.includes(k)) ? url : false; } catch (e) { console.warn(`Error fetching ${url}:`, e.message); return false; } }; const badSiteFound = await Promise.any(uniqueLinks.map(scanShortener)); if (!badSiteFound) return;