printhive/lib/downloadBlock.js
dlawler489 ef2093b73f Say when MakerWorld is waiting for you to prove you're not a robot
The challenge was detected but treated as an ordinary download failure, so
the message didn't say that only you can clear it. Now it stops the run,
is remembered centrally, and watches skip downloads while it stands —
metadata still imports, and models stay partial for "Get files". The
Watched page shows a banner with a link to MakerWorld and an "I've solved
it" button; a successful download clears it too. Detection also covers a
challenge page returned where JSON was expected.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-20 15:44:54 +10:00

29 lines
1.1 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 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 };