Sub-Store 小课堂: 根据请求头内容自动过滤协议
例如根据 Surge 客户端实际解锁了哪些来进行筛选
可让 AI 帮忙修改 我人废了
function operator(proxies, target, context) {
if ($options?._req) {
const { headers, url, path } = $options?._req || {};
// 获取 user-agent
const ua = headers?.["user-agent"] || headers?.["User-Agent"];
console.log(
let types = [];
if (target === "Surge") {
const isSurgeiOS = ua?.startsWith("Surge iOS/");
if (isSurgeiOS) {
// 获取 Surge 已解锁的功能
const features = (
headers?.["x-surge-unlocked-features"] ||
headers?.["X-Surge-Unlocked-Features"]
)?.split(/\s,\s/);
console.log(
// 如果能取到 Surge 已解锁的功能 并且 里面没有 anytls, 就过滤掉 anytls
if (features && !features.includes("anytls")) {
types.push("anytls");
}
} else if (
ua?.startsWith("Surge Mac/") &&
ua?.match(/\/(\d+)/)?.[1] < 9860
) {
// 若 Surge Mac 版本小于 9860,就过滤掉 anytls
types.push("anytls");
}
} else if (target === "Egern") {
const build = ua?.match(/Build\/(\d+)/)?.[1];
console.log(
// 更旧的版本里 user-agent 里没 build
// 判断旧版 就过滤掉 anytls
if (ua?.startsWith("egern/") && (!build || build < 718)) {
types.push("anytls");
}
}
return proxies.filter((proxy) => !types.includes(proxy.type));
}
return proxies;
}
🤭 Sub-Store 合集 🧐 频道资源合集 😄 恰饭推荐 💬 群组
🥰 #SubStore #Sub-Store #小课堂 #tips #协议 #协议筛选 #筛选 #过滤 #节点 #请求 #请求头
例如根据 Surge 客户端实际解锁了哪些来进行筛选
可让 AI 帮忙修改 我人废了
function operator(proxies, target, context) {
if ($options?._req) {
const { headers, url, path } = $options?._req || {};
// 获取 user-agent
const ua = headers?.["user-agent"] || headers?.["User-Agent"];
console.log(
User-Agent: ${ua});let types = [];
if (target === "Surge") {
const isSurgeiOS = ua?.startsWith("Surge iOS/");
if (isSurgeiOS) {
// 获取 Surge 已解锁的功能
const features = (
headers?.["x-surge-unlocked-features"] ||
headers?.["X-Surge-Unlocked-Features"]
)?.split(/\s,\s/);
console.log(
Surge 已解锁的功能: ${features});// 如果能取到 Surge 已解锁的功能 并且 里面没有 anytls, 就过滤掉 anytls
if (features && !features.includes("anytls")) {
types.push("anytls");
}
} else if (
ua?.startsWith("Surge Mac/") &&
ua?.match(/\/(\d+)/)?.[1] < 9860
) {
// 若 Surge Mac 版本小于 9860,就过滤掉 anytls
types.push("anytls");
}
} else if (target === "Egern") {
const build = ua?.match(/Build\/(\d+)/)?.[1];
console.log(
Egern Build: ${build});// 更旧的版本里 user-agent 里没 build
// 判断旧版 就过滤掉 anytls
if (ua?.startsWith("egern/") && (!build || build < 718)) {
types.push("anytls");
}
}
return proxies.filter((proxy) => !types.includes(proxy.type));
}
return proxies;
}
🤭 Sub-Store 合集 🧐 频道资源合集 😄 恰饭推荐 💬 群组
🥰 #SubStore #Sub-Store #小课堂 #tips #协议 #协议筛选 #筛选 #过滤 #节点 #请求 #请求头