// When a site blocks downloads until you prove you're not a robot. // // MakerWorld does this after a few downloads in a row. Only you can clear it — // by solving the check in your own browser — so Printhive stops asking until // you say you have. Attempts while blocked are wasted and may prolong it. // // Held in memory: a restart clears it, and the next attempt finds out again. const blocks = new Map(); // site → { since, message } const DEFAULT = 'MakerWorld is asking you to confirm you’re not a robot before it will allow more downloads.'; function block(site, message = DEFAULT) { if (!blocks.has(site)) blocks.set(site, { since: new Date(), message }); return blocks.get(site); } // Called when you say you've solved it, and whenever a download succeeds. function clear(site) { return blocks.delete(site); } const isBlocked = (site) => blocks.has(site); function state(site) { const b = blocks.get(site); return b ? { blocked: true, since: b.since, message: b.message } : { blocked: false }; } module.exports = { block, clear, isBlocked, state, DEFAULT };