// ==UserScript==
// @name         4chan Fumigation Protocol
// @namespace    local
// @version      4.0
// @match        https://boards.4chan.org/e/thread/*
// @author       !SX2ZRK62WM
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    const LETHAL_DOSAGE = 70;
    const BUG_SIZE = 900;

    const _0x5f21 = [55, 2, 2, 2, 5, 10, 10, 7, 7, 5, 50, 5, 5, 55, -10, -35, -5, -35];

    const hiveCore = document.querySelector('.subject');
    if (!hiveCore) return;

    const isContaminated = hiveCore.textContent.toLowerCase().includes('/edg/');
    if (!isContaminated) return;

    function getIncubationPeriod(specimen) {
        const pulse = specimen.querySelector('time');
        if (!pulse) return null;
        const timeLog = pulse.getAttribute('datetime');
        return timeLog ? new Date(timeLog).getTime() : null;
    }

    function dissectPathogen(specimen) {
        const residue = specimen.querySelector('.fileText');
        if (!residue) return null;
        const link = residue.querySelector('a');
        if (!link) return null;

        const tag = link.textContent || '';
        const rawData = residue.textContent || '';
        const massMatch = rawData.match(/\(([\d.]+)\s*(KB|MB)/i);

        let weight = null;
        if (massMatch) {
            const mag = parseFloat(massMatch[1]);
            const scale = massMatch[2].toUpperCase();
            weight = scale === 'MB' ? mag * 1024 : mag;
        }

        const secretion = specimen.querySelector('.postMessage');
        const content = secretion ? secretion.textContent.trim() : '';

        return { tag, weight, content };
    }

    function assessInfestation(specimen) {
        const data = dissectPathogen(specimen);
        if (!data) return { ppm: 0 };

        let ppm = 0;
        const label = data.tag;

        if (data.weight !== null && data.weight < 150) ppm += 35;
        if (data.weight !== null && data.weight < BUG_SIZE) ppm += _0x5f21[0];
        if (data.weight !== null && data.weight > 2072) ppm += _0x5f21[17];
        if (/\s/.test(label)) ppm += _0x5f21[14];

        const serialMatch = label.match(/^(\d+)-/);
        if (serialMatch) {
            if (serialMatch[1].length == 5 && parseInt(serialMatch[1], 10) > 50) {
                ppm += _0x5f21[10];
            }
        }

        if (label.replace(/\.[^.]+$/, '').length < 10) ppm += _0x5f21[4];
        if (/[a-zA-Z]{6,}/.test(label)) ppm += _0x5f21[11];
        if (/[-_][a-zA-Z0-9][-_]/.test(label)) ppm += _0x5f21[12];
        if (label.includes('_')) ppm += _0x5f21[1];
        if (label.includes('-')) ppm += _0x5f21[2];
        if (label.includes('_') && label.includes('-')) ppm += _0x5f21[3];
        if (/\d[a-zA-Z]\d/.test(label)) ppm += _0x5f21[5];
        if (/[a-zA-Z]\d[a-zA-Z]/.test(label)) ppm += _0x5f21[6];
        if (/[aeiou]{3}/i.test(label)) ppm += _0x5f21[7];
        if (/[A-Z]{3}/.test(label)) ppm += _0x5f21[8];
        if ((label.match(/[A-Z]/g) || []).length >= 3) ppm += _0x5f21[9];
        if (data.content.length > 0) ppm += _0x5f21[16];

        return { ppm };
    }

    function applyFumigant(specimen) {
        if (specimen.dataset.purged) return;
        specimen.dataset.purged = 'true';
        const nest = specimen.closest('.postContainer') || specimen;
        nest.remove();
    }

    function scanBiohazard() {
        const samples = [...document.querySelectorAll('.post.reply:has(.file)')];
        let lastPulse = null;

        for (const unit of samples) {
            const report = assessInfestation(unit);
            const currentPulse = getIncubationPeriod(unit);

            if (currentPulse && lastPulse) {
                const delta = (currentPulse - lastPulse) / 1000;
                if (delta < 60) report.ppm += _0x5f21[13];
                else if (delta > 100) report.ppm += _0x5f21[15];
            }

            if (currentPulse) lastPulse = currentPulse;

            if (report.ppm >= LETHAL_DOSAGE) {
                applyFumigant(unit);
            }
        }
    }

    scanBiohazard();

    const breedingGround = document.querySelector('.thread');
    if (breedingGround) {
        const exterminator = new MutationObserver((logs) => {
            if (logs.some(l => l.addedNodes.length > 0)) {
                scanBiohazard();
            }
        });

        exterminator.observe(breedingGround, {
            childList: true,
            subtree: false
        });
    }
})();

Install violentmonkey/tampermonkey and paste the code as a new userscript.
The updates will not always be announced. Come and check periodically for updates.
Alt Tag

Edit

Pub: 23 Apr 2026 05:50 UTC

Edit: 11 May 2026 06:30 UTC

Views: 178