···258258 this.queue = [];
259259 this.activeCount = 0;
260260 this.furaffinityActive = false;
261261+ this.activeLinks = []; // Track currently processing links
261262 }
262263263264 enqueue(item) {
···267268268269 next() {
269270 if (this.queue.length === 0) return;
270270- // Check for FurAffinity link at the front
271271+ // Check if any active link is a FurAffinity link
272272+ const faActive = this.activeLinks.some(link => link && /^https?:\/\/(www\.)?furaffinity\.net\//i.test(link.url));
273273+ // Check for FurAffinity link in the queue
271274 const faIndex = this.queue.findIndex(item => /^https?:\/\/(www\.)?furaffinity\.net\//i.test(item.url));
272272- if (faIndex !== -1 && !this.furaffinityActive && this.activeCount < this.concurrency) {
273273- // Process only one FurAffinity link at a time
275275+ // Only allow one FA link in activeLinks at a time
276276+ if (faIndex !== -1 && !faActive && !this.furaffinityActive && this.activeCount < this.concurrency) {
274277 const [item] = this.queue.splice(faIndex, 1);
275278 this.furaffinityActive = true;
276279 this.activeCount++;
280280+ this.activeLinks.push(item);
277281 console.log(`[AsyncLinkQueue] Processing FurAffinity link: ${item.url} (10s delay before next FA link allowed)`);
278282 this.processFn(item)
279283 .catch(() => {})
280284 .finally(() => {
281285 this.activeCount--;
286286+ this.activeLinks = this.activeLinks.filter(l => l !== item);
282287 setTimeout(() => {
283288 this.furaffinityActive = false;
284289 console.log('[AsyncLinkQueue] FurAffinity delay complete, next link can be processed.');
285290 this.next();
286286- }, 10000); // 10s enforced delay after FA link
291291+ }, 10000);
287292 });
288288- return;
293293+ // Do not return; allow non-FA links to fill other slots
289294 }
290290- // Otherwise, process up to concurrency for non-FA links
295295+ // Process up to concurrency for non-FA links (but never process a FA link if one is active)
291296 while (this.activeCount < this.concurrency) {
297297+ // Only pick non-FA links if a FA link is already active or in cooldown
292298 const idx = this.queue.findIndex(item => !/^https?:\/\/(www\.)?furaffinity\.net\//i.test(item.url));
293299 if (idx === -1) break;
294300 const [item] = this.queue.splice(idx, 1);
295301 this.activeCount++;
302302+ this.activeLinks.push(item);
296303 this.processFn(item)
297304 .catch(() => {})
298305 .finally(() => {
299306 this.activeCount--;
300300- setTimeout(() => this.next(), 4000); // 4s cooldown for non-FurAffinity links
307307+ this.activeLinks = this.activeLinks.filter(l => l !== item);
308308+ setTimeout(() => this.next(), 4000);
301309 });
302310 }
303311 }