Add script demo

This commit is contained in:
Peng-YM
2020-09-21 13:23:05 +08:00
parent 32595ee27e
commit d81a0e2d3f
3 changed files with 31 additions and 14 deletions

View File

@@ -1,10 +1,17 @@
function operator(proxies) {
const counter = {};
return proxies.map(p => {
if (!counter[p.name]) counter[p.name] = 0;
++counter[p.name];
const num = "00000" + counter[p.name];
p.name = p.name + " " + num.substr(num.length-2);
return p;
});
}
const counter = {};
const increment = {};
proxies.forEach((p) => {
if (typeof counter[p.name] === 'undefined') counter[p.name] = 1;
else counter[p.name]++;
});
console.log(counter);
return proxies.map((p) => {
if (counter[p.name] > 1) {
if (typeof increment[p.name] === "undefined") increment[p.name] = 1;
const num = "00000" + increment[p.name]++;
p.name = p.name + " " + num.substr(num.length - 2);
}
return p;
});
}

3
scripts/udp-filter.js Normal file
View File

@@ -0,0 +1,3 @@
function filter(proxies) {
return proxies.map(p => p.udp);
}