Skip to content

Commit e0fe2ce

Browse files
committed
fix: 优化批量替换域名函数,随机化主机选择以提高多样性
1 parent 48611ba commit e0fe2ce

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

_worker.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,9 +870,10 @@ function 随机替换通配符(h) {
870870
}
871871

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

0 commit comments

Comments
 (0)