To keep one proxy for four attempts, group the attempt index before cycling through the list. Given a validated nonempty proxies array and a zero-based nonnegative integer i:

const proxy = proxies[Math.floor(i / 4) % proxies.length];

Indices 0–3 select the first entry, 4–7 the second, and 8–11 the third. The remainder wraps the group number back to the first proxy after the last entry. Reject an empty array before using this expression.

Use the selected URL when configuring that attempt’s HTTP client. The free proxy list supplies public candidates for the array; format each URL with a protocol that client supports. The arithmetic schedules endpoints; it does not change a browser or an already connected client by itself.

Decide whether a retry consumes another attempt index. A success counter would produce a different policy, and parallel tasks may finish in a different order from the indices assigned to them.

Mikanda mikatakata