mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-11 10:39:01 +08:00
feat: Loon 解析器支持参数 ua=clash.meta&timeout=3000, 支持从链接重新获取
This commit is contained in:
parent
a8a89ee2a2
commit
47f26bdac8
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sub-store",
|
"name": "sub-store",
|
||||||
"version": "2.14.209",
|
"version": "2.14.210",
|
||||||
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
|
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
|
||||||
"main": "src/main.js",
|
"main": "src/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -2,28 +2,79 @@
|
|||||||
import { ProxyUtils } from '@/core/proxy-utils';
|
import { ProxyUtils } from '@/core/proxy-utils';
|
||||||
import { RuleUtils } from '@/core/rule-utils';
|
import { RuleUtils } from '@/core/rule-utils';
|
||||||
import { version } from '../../package.json';
|
import { version } from '../../package.json';
|
||||||
|
import download from '@/utils/download';
|
||||||
|
|
||||||
console.log(
|
let result = '';
|
||||||
`
|
let resource = typeof $resource !== 'undefined' ? $resource : '';
|
||||||
┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅
|
let resourceType = typeof $resourceType !== 'undefined' ? $resourceType : '';
|
||||||
Sub-Store -- v${version}
|
let resourceUrl = typeof $resourceUrl !== 'undefined' ? $resourceUrl : '';
|
||||||
┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅
|
|
||||||
`,
|
|
||||||
);
|
|
||||||
|
|
||||||
const RESOURCE_TYPE = {
|
!(async () => {
|
||||||
PROXY: 1,
|
console.log(
|
||||||
RULE: 2,
|
`
|
||||||
};
|
┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅
|
||||||
|
Sub-Store -- v${version}
|
||||||
|
┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅
|
||||||
|
`,
|
||||||
|
);
|
||||||
|
|
||||||
let result = $resource;
|
let arg;
|
||||||
|
if (typeof $argument != 'undefined') {
|
||||||
|
arg = Object.fromEntries(
|
||||||
|
$argument.split('&').map((item) => item.split('=')),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
arg = {};
|
||||||
|
}
|
||||||
|
|
||||||
if ($resourceType === RESOURCE_TYPE.PROXY) {
|
const RESOURCE_TYPE = {
|
||||||
const proxies = ProxyUtils.parse($resource);
|
PROXY: 1,
|
||||||
result = ProxyUtils.produce(proxies, 'Loon');
|
RULE: 2,
|
||||||
} else if ($resourceType === RESOURCE_TYPE.RULE) {
|
};
|
||||||
const rules = RuleUtils.parse($resource);
|
|
||||||
result = RuleUtils.produce(rules, 'Loon');
|
|
||||||
}
|
|
||||||
|
|
||||||
$done(result);
|
result = resource;
|
||||||
|
|
||||||
|
if (resourceType === RESOURCE_TYPE.PROXY) {
|
||||||
|
try {
|
||||||
|
let proxies = ProxyUtils.parse(resource);
|
||||||
|
result = ProxyUtils.produce(proxies, 'Loon');
|
||||||
|
} catch (e) {
|
||||||
|
console.log('解析器: 使用 resource 出现错误');
|
||||||
|
console.log(e.message ?? e);
|
||||||
|
}
|
||||||
|
if ((!result || /^\s*$/.test(result)) && resourceUrl) {
|
||||||
|
console.log(`解析器: 尝试从 ${resourceUrl} 获取订阅`);
|
||||||
|
try {
|
||||||
|
let raw = await download(resourceUrl, arg?.ua, arg?.timeout);
|
||||||
|
let proxies = ProxyUtils.parse(raw);
|
||||||
|
result = ProxyUtils.produce(proxies, 'Loon');
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e.message ?? e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (resourceType === RESOURCE_TYPE.RULE) {
|
||||||
|
try {
|
||||||
|
const rules = RuleUtils.parse(resource);
|
||||||
|
result = RuleUtils.produce(rules, 'Loon');
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e.message ?? e);
|
||||||
|
}
|
||||||
|
if ((!result || /^\s*$/.test(result)) && resourceUrl) {
|
||||||
|
console.log(`解析器: 尝试从 ${resourceUrl} 获取规则`);
|
||||||
|
try {
|
||||||
|
let raw = await download(resourceUrl, arg?.ua, arg?.timeout);
|
||||||
|
let rules = RuleUtils.parse(raw);
|
||||||
|
result = RuleUtils.produce(rules, 'Loon');
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e.message ?? e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})()
|
||||||
|
.catch(async (e) => {
|
||||||
|
console.log('解析器: 出现错误');
|
||||||
|
console.log(e.message ?? e);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
$done(result || '');
|
||||||
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user