mirror of
https://github.com/lush2020/CF-Workers-SUB.git
synced 2026-03-21 11:02:41 +08:00
更新_worker.js,优化base64订阅转换逻辑;
This commit is contained in:
27
_worker.js
27
_worker.js
@@ -126,6 +126,18 @@ export default {
|
|||||||
console.log(请求订阅响应内容);
|
console.log(请求订阅响应内容);
|
||||||
req_data += 请求订阅响应内容[0].join('\n');
|
req_data += 请求订阅响应内容[0].join('\n');
|
||||||
订阅转换URL += "|" + 请求订阅响应内容[1];
|
订阅转换URL += "|" + 请求订阅响应内容[1];
|
||||||
|
if (订阅格式 == 'base64' && !userAgent.includes('subconverter') && 请求订阅响应内容[1].includes('://')) {
|
||||||
|
subConverterUrl = `${subProtocol}://${subConverter}/sub?target=mixed&url=${encodeURIComponent(请求订阅响应内容[1])}&insert=false&config=${encodeURIComponent(subConfig)}&emoji=true&list=false&tfo=false&scv=true&fdn=false&sort=false&new_name=true`;
|
||||||
|
try {
|
||||||
|
const subConverterResponse = await fetch(subConverterUrl);
|
||||||
|
if (subConverterResponse.ok) {
|
||||||
|
const subConverterContent = await subConverterResponse.text();
|
||||||
|
req_data += '\n' + atob(subConverterContent);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log('订阅转换请回base64失败,检查订阅转换后端是否正常运行');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (env.WARP) 订阅转换URL += "|" + (await ADD(env.WARP)).join("|");
|
if (env.WARP) 订阅转换URL += "|" + (await ADD(env.WARP)).join("|");
|
||||||
@@ -138,22 +150,9 @@ export default {
|
|||||||
|
|
||||||
//去重
|
//去重
|
||||||
const uniqueLines = new Set(text.split('\n'));
|
const uniqueLines = new Set(text.split('\n'));
|
||||||
let result = [...uniqueLines].join('\n');
|
const result = [...uniqueLines].join('\n');
|
||||||
//console.log(result);
|
//console.log(result);
|
||||||
|
|
||||||
if (订阅格式 == 'base64' && !userAgent.includes('subconverter') && 订阅转换URL.includes('://')) {
|
|
||||||
subConverterUrl = `${subProtocol}://${subConverter}/sub?target=mixed&url=${encodeURIComponent(订阅转换URL)}&insert=false&config=${encodeURIComponent(subConfig)}&emoji=true&list=false&tfo=false&scv=true&fdn=false&sort=false&new_name=true`;
|
|
||||||
try {
|
|
||||||
const subConverterResponse = await fetch(subConverterUrl);
|
|
||||||
if (subConverterResponse.ok) {
|
|
||||||
const subConverterContent = await subConverterResponse.text();
|
|
||||||
result += '\n' + atob(subConverterContent);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.log('订阅转换请回base64失败,检查订阅转换后端是否正常运行');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let base64Data;
|
let base64Data;
|
||||||
try {
|
try {
|
||||||
base64Data = btoa(result);
|
base64Data = btoa(result);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
name = "sub-worker"
|
name = "sub-worker"
|
||||||
main = "_worker.js"
|
main = "_worker.js"
|
||||||
compatibility_date = "2025-07-07"
|
compatibility_date = "2025-07-23"
|
||||||
keep_vars = true
|
keep_vars = true
|
||||||
Reference in New Issue
Block a user