mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-07-31 06:22:01 +08:00
Added global variables for Loon to ScriptOperator and ScriptFilter
This commit is contained in:
parent
9e05c8d7f0
commit
97de476ae3
4
backend/dist/sub-store-parser.loon.min.js
vendored
4
backend/dist/sub-store-parser.loon.min.js
vendored
File diff suppressed because one or more lines are too long
@ -1,4 +1,3 @@
|
|||||||
import { HTTP } from '../../vendor/open-api';
|
|
||||||
import { isIPv4, isIPv6 } from '../../utils';
|
import { isIPv4, isIPv6 } from '../../utils';
|
||||||
import { FULL } from '../../utils/logical';
|
import { FULL } from '../../utils/logical';
|
||||||
import { getFlag } from '../../utils/geo';
|
import { getFlag } from '../../utils/geo';
|
||||||
@ -211,12 +210,11 @@ function ScriptOperator(script, targetPlatform, $arguments) {
|
|||||||
func: async (proxies) => {
|
func: async (proxies) => {
|
||||||
let output = proxies;
|
let output = proxies;
|
||||||
await (async function () {
|
await (async function () {
|
||||||
const operator = new Function(
|
const operator = createDynamicFunction(
|
||||||
'$arguments',
|
'operator',
|
||||||
'HTTP',
|
script,
|
||||||
'lodash',
|
$arguments,
|
||||||
`${script}\n return operator`,
|
);
|
||||||
)($arguments, HTTP, lodash);
|
|
||||||
output = operator(proxies, targetPlatform);
|
output = operator(proxies, targetPlatform);
|
||||||
})();
|
})();
|
||||||
return output;
|
return output;
|
||||||
@ -425,12 +423,11 @@ function ScriptFilter(script, targetPlatform, $arguments) {
|
|||||||
func: async (proxies) => {
|
func: async (proxies) => {
|
||||||
let output = FULL(proxies.length, true);
|
let output = FULL(proxies.length, true);
|
||||||
await (async function () {
|
await (async function () {
|
||||||
const filter = new Function(
|
const filter = createDynamicFunction(
|
||||||
'$arguments',
|
'filter',
|
||||||
'HTTP',
|
script,
|
||||||
'lodash',
|
$arguments,
|
||||||
`${script}\n return filter`,
|
);
|
||||||
)($arguments, HTTP, lodash);
|
|
||||||
output = filter(proxies, targetPlatform);
|
output = filter(proxies, targetPlatform);
|
||||||
})();
|
})();
|
||||||
return output;
|
return output;
|
||||||
@ -520,3 +517,34 @@ function removeFlag(str) {
|
|||||||
.replace(/[\uD83C][\uDDE6-\uDDFF][\uD83C][\uDDE6-\uDDFF]/g, '')
|
.replace(/[\uD83C][\uDDE6-\uDDFF][\uD83C][\uDDE6-\uDDFF]/g, '')
|
||||||
.trim();
|
.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createDynamicFunction(name, script, $arguments) {
|
||||||
|
if ($.env.isLoon) {
|
||||||
|
return new Function(
|
||||||
|
'$arguments',
|
||||||
|
'$substore',
|
||||||
|
'lodash',
|
||||||
|
'$persistentStore',
|
||||||
|
'$httpClient',
|
||||||
|
'$notification',
|
||||||
|
`${script}\n return ${name}`,
|
||||||
|
)(
|
||||||
|
$arguments,
|
||||||
|
$,
|
||||||
|
lodash,
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
|
$persistentStore,
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
|
$httpClient,
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
|
$notification,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return new Function(
|
||||||
|
'$arguments',
|
||||||
|
'$substore',
|
||||||
|
'lodash',
|
||||||
|
`${script}\n return ${name}`,
|
||||||
|
)($arguments, $, lodash);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
4
backend/sub-store.min.js
vendored
4
backend/sub-store.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user