fix: 修正批量替换域名函数中的随机主机选择逻辑

This commit is contained in:
cmliu
2025-12-26 00:23:01 +08:00
parent 1977bb1825
commit b9cb7f75b9

View File

@@ -900,7 +900,7 @@ function 批量替换域名(内容, hosts, 每组数量 = 2) {
const 打乱后数组 = [...hosts].sort(() => Math.random() - 0.5);
let count = 0, currentRandomHost = null;
return 内容.replace(/example\.com/g, () => {
if (count % 每组数量 === 0) currentRandomHost = 随机替换通配符(打乱后数组[count % 打乱后数组.length]);
if (count % 每组数量 === 0) currentRandomHost = 随机替换通配符(打乱后数组[Math.floor(count / 每组数量) % 打乱后数组.length]);
count++;
return currentRandomHost;
});