Added script filter and script opeartor

This commit is contained in:
Peng-YM
2020-09-03 16:16:28 +08:00
parent 82a8c16e51
commit 250afb10a2
8 changed files with 286 additions and 181 deletions

View File

@@ -20,8 +20,14 @@
</component>
<component name="ChangeListManager">
<list default="true" id="8b97a098-48b2-4e64-a9ef-522fe2d30b52" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/../web/src/components/ScriptFilter.vue" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../web/src/components/ScriptOperator.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/sub-store.js" beforeDir="false" afterPath="$PROJECT_DIR$/sub-store.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../web/package-lock.json" beforeDir="false" afterPath="$PROJECT_DIR$/../web/package-lock.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../web/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/../web/package.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../web/src/views/SubEditor.vue" beforeDir="false" afterPath="$PROJECT_DIR$/../web/src/views/SubEditor.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../web/src/views/Subscription.vue" beforeDir="false" afterPath="$PROJECT_DIR$/../web/src/views/Subscription.vue" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -98,7 +104,7 @@
<workItem from="1599095538624" duration="1682000" />
<workItem from="1599098635956" duration="82000" />
<workItem from="1599099268523" duration="934000" />
<workItem from="1599108801252" duration="56000" />
<workItem from="1599108801252" duration="4543000" />
</task>
<servers />
</component>
@@ -118,7 +124,7 @@
<option name="oldMeFiltersMigrated" value="true" />
</component>
<component name="WindowStateProjectService">
<state width="1322" height="440" key="GridCell.Tab.0.bottom" timestamp="1599100319941">
<state width="1322" height="302" key="GridCell.Tab.0.bottom" timestamp="1599120743218">
<screen x="70" y="23" width="2490" height="1417" />
</state>
<state width="840" height="374" key="GridCell.Tab.0.bottom/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358068" />
@@ -129,8 +135,8 @@
<state width="849" height="374" key="GridCell.Tab.0.bottom/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992684" />
<state width="840" height="374" key="GridCell.Tab.0.bottom/67.23.1725.1097@67.23.1725.1097" timestamp="1598947305944" />
<state width="840" height="374" key="GridCell.Tab.0.bottom/70.23.1722.1097@70.23.1722.1097" timestamp="1598946266532" />
<state width="1322" height="440" key="GridCell.Tab.0.bottom/70.23.2490.1417@70.23.2490.1417" timestamp="1599100319941" />
<state width="1322" height="440" key="GridCell.Tab.0.center" timestamp="1599100319940">
<state width="1322" height="302" key="GridCell.Tab.0.bottom/70.23.2490.1417@70.23.2490.1417" timestamp="1599120743218" />
<state width="1322" height="302" key="GridCell.Tab.0.center" timestamp="1599120743218">
<screen x="70" y="23" width="2490" height="1417" />
</state>
<state width="840" height="374" key="GridCell.Tab.0.center/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358067" />
@@ -141,8 +147,8 @@
<state width="849" height="374" key="GridCell.Tab.0.center/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992684" />
<state width="840" height="374" key="GridCell.Tab.0.center/67.23.1725.1097@67.23.1725.1097" timestamp="1598947305944" />
<state width="840" height="374" key="GridCell.Tab.0.center/70.23.1722.1097@70.23.1722.1097" timestamp="1598946266532" />
<state width="1322" height="440" key="GridCell.Tab.0.center/70.23.2490.1417@70.23.2490.1417" timestamp="1599100319940" />
<state width="1322" height="440" key="GridCell.Tab.0.left" timestamp="1599100319940">
<state width="1322" height="302" key="GridCell.Tab.0.center/70.23.2490.1417@70.23.2490.1417" timestamp="1599120743218" />
<state width="1322" height="302" key="GridCell.Tab.0.left" timestamp="1599120743217">
<screen x="70" y="23" width="2490" height="1417" />
</state>
<state width="840" height="374" key="GridCell.Tab.0.left/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358067" />
@@ -153,8 +159,8 @@
<state width="849" height="374" key="GridCell.Tab.0.left/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992683" />
<state width="840" height="374" key="GridCell.Tab.0.left/67.23.1725.1097@67.23.1725.1097" timestamp="1598947305944" />
<state width="840" height="374" key="GridCell.Tab.0.left/70.23.1722.1097@70.23.1722.1097" timestamp="1598946266531" />
<state width="1322" height="440" key="GridCell.Tab.0.left/70.23.2490.1417@70.23.2490.1417" timestamp="1599100319940" />
<state width="1322" height="440" key="GridCell.Tab.0.right" timestamp="1599100319941">
<state width="1322" height="302" key="GridCell.Tab.0.left/70.23.2490.1417@70.23.2490.1417" timestamp="1599120743217" />
<state width="1322" height="302" key="GridCell.Tab.0.right" timestamp="1599120743218">
<screen x="70" y="23" width="2490" height="1417" />
</state>
<state width="840" height="374" key="GridCell.Tab.0.right/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358068" />
@@ -165,8 +171,8 @@
<state width="849" height="374" key="GridCell.Tab.0.right/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992684" />
<state width="840" height="374" key="GridCell.Tab.0.right/67.23.1725.1097@67.23.1725.1097" timestamp="1598947305944" />
<state width="840" height="374" key="GridCell.Tab.0.right/70.23.1722.1097@70.23.1722.1097" timestamp="1598946266532" />
<state width="1322" height="440" key="GridCell.Tab.0.right/70.23.2490.1417@70.23.2490.1417" timestamp="1599100319941" />
<state width="1322" height="440" key="GridCell.Tab.1.bottom" timestamp="1599100319942">
<state width="1322" height="302" key="GridCell.Tab.0.right/70.23.2490.1417@70.23.2490.1417" timestamp="1599120743218" />
<state width="1322" height="302" key="GridCell.Tab.1.bottom" timestamp="1599120743140">
<screen x="70" y="23" width="2490" height="1417" />
</state>
<state width="840" height="374" key="GridCell.Tab.1.bottom/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358069" />
@@ -177,8 +183,8 @@
<state width="849" height="374" key="GridCell.Tab.1.bottom/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992587" />
<state width="840" height="374" key="GridCell.Tab.1.bottom/67.23.1725.1097@67.23.1725.1097" timestamp="1598947305945" />
<state width="840" height="374" key="GridCell.Tab.1.bottom/70.23.1722.1097@70.23.1722.1097" timestamp="1598932593853" />
<state width="1322" height="440" key="GridCell.Tab.1.bottom/70.23.2490.1417@70.23.2490.1417" timestamp="1599100319942" />
<state width="1322" height="440" key="GridCell.Tab.1.center" timestamp="1599100319941">
<state width="1322" height="302" key="GridCell.Tab.1.bottom/70.23.2490.1417@70.23.2490.1417" timestamp="1599120743140" />
<state width="1322" height="302" key="GridCell.Tab.1.center" timestamp="1599120743140">
<screen x="70" y="23" width="2490" height="1417" />
</state>
<state width="840" height="374" key="GridCell.Tab.1.center/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358069" />
@@ -189,8 +195,8 @@
<state width="849" height="374" key="GridCell.Tab.1.center/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992587" />
<state width="840" height="374" key="GridCell.Tab.1.center/67.23.1725.1097@67.23.1725.1097" timestamp="1598947305944" />
<state width="840" height="374" key="GridCell.Tab.1.center/70.23.1722.1097@70.23.1722.1097" timestamp="1598932593853" />
<state width="1322" height="440" key="GridCell.Tab.1.center/70.23.2490.1417@70.23.2490.1417" timestamp="1599100319941" />
<state width="1322" height="440" key="GridCell.Tab.1.left" timestamp="1599100319941">
<state width="1322" height="302" key="GridCell.Tab.1.center/70.23.2490.1417@70.23.2490.1417" timestamp="1599120743140" />
<state width="1322" height="302" key="GridCell.Tab.1.left" timestamp="1599120743139">
<screen x="70" y="23" width="2490" height="1417" />
</state>
<state width="840" height="374" key="GridCell.Tab.1.left/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358069" />
@@ -201,8 +207,8 @@
<state width="849" height="374" key="GridCell.Tab.1.left/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992587" />
<state width="840" height="374" key="GridCell.Tab.1.left/67.23.1725.1097@67.23.1725.1097" timestamp="1598947305944" />
<state width="840" height="374" key="GridCell.Tab.1.left/70.23.1722.1097@70.23.1722.1097" timestamp="1598932593852" />
<state width="1322" height="440" key="GridCell.Tab.1.left/70.23.2490.1417@70.23.2490.1417" timestamp="1599100319941" />
<state width="1322" height="440" key="GridCell.Tab.1.right" timestamp="1599100319942">
<state width="1322" height="302" key="GridCell.Tab.1.left/70.23.2490.1417@70.23.2490.1417" timestamp="1599120743139" />
<state width="1322" height="302" key="GridCell.Tab.1.right" timestamp="1599120743140">
<screen x="70" y="23" width="2490" height="1417" />
</state>
<state width="840" height="374" key="GridCell.Tab.1.right/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358069" />
@@ -213,8 +219,8 @@
<state width="849" height="374" key="GridCell.Tab.1.right/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992587" />
<state width="840" height="374" key="GridCell.Tab.1.right/67.23.1725.1097@67.23.1725.1097" timestamp="1598947305944" />
<state width="840" height="374" key="GridCell.Tab.1.right/70.23.1722.1097@70.23.1722.1097" timestamp="1598932593853" />
<state width="1322" height="440" key="GridCell.Tab.1.right/70.23.2490.1417@70.23.2490.1417" timestamp="1599100319942" />
<state width="1322" height="440" key="GridCell.Tab.2.bottom" timestamp="1599100319943">
<state width="1322" height="302" key="GridCell.Tab.1.right/70.23.2490.1417@70.23.2490.1417" timestamp="1599120743140" />
<state width="1322" height="302" key="GridCell.Tab.2.bottom" timestamp="1599120743141">
<screen x="70" y="23" width="2490" height="1417" />
</state>
<state width="840" height="374" key="GridCell.Tab.2.bottom/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358071" />
@@ -225,8 +231,8 @@
<state width="849" height="374" key="GridCell.Tab.2.bottom/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992588" />
<state width="840" height="374" key="GridCell.Tab.2.bottom/67.23.1725.1097@67.23.1725.1097" timestamp="1598947305945" />
<state width="1300" height="374" key="GridCell.Tab.2.bottom/70.23.1722.1097@70.23.1722.1097" timestamp="1598931659637" />
<state width="1322" height="440" key="GridCell.Tab.2.bottom/70.23.2490.1417@70.23.2490.1417" timestamp="1599100319943" />
<state width="1322" height="440" key="GridCell.Tab.2.center" timestamp="1599100319942">
<state width="1322" height="302" key="GridCell.Tab.2.bottom/70.23.2490.1417@70.23.2490.1417" timestamp="1599120743140" />
<state width="1322" height="302" key="GridCell.Tab.2.center" timestamp="1599120743140">
<screen x="70" y="23" width="2490" height="1417" />
</state>
<state width="840" height="374" key="GridCell.Tab.2.center/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358070" />
@@ -237,8 +243,8 @@
<state width="849" height="374" key="GridCell.Tab.2.center/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992588" />
<state width="840" height="374" key="GridCell.Tab.2.center/67.23.1725.1097@67.23.1725.1097" timestamp="1598947305945" />
<state width="1300" height="374" key="GridCell.Tab.2.center/70.23.1722.1097@70.23.1722.1097" timestamp="1598931659636" />
<state width="1322" height="440" key="GridCell.Tab.2.center/70.23.2490.1417@70.23.2490.1417" timestamp="1599100319942" />
<state width="1322" height="440" key="GridCell.Tab.2.left" timestamp="1599100319942">
<state width="1322" height="302" key="GridCell.Tab.2.center/70.23.2490.1417@70.23.2490.1417" timestamp="1599120743140" />
<state width="1322" height="302" key="GridCell.Tab.2.left" timestamp="1599120743140">
<screen x="70" y="23" width="2490" height="1417" />
</state>
<state width="840" height="374" key="GridCell.Tab.2.left/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358070" />
@@ -249,8 +255,8 @@
<state width="849" height="374" key="GridCell.Tab.2.left/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992587" />
<state width="840" height="374" key="GridCell.Tab.2.left/67.23.1725.1097@67.23.1725.1097" timestamp="1598947305945" />
<state width="1300" height="374" key="GridCell.Tab.2.left/70.23.1722.1097@70.23.1722.1097" timestamp="1598931659636" />
<state width="1322" height="440" key="GridCell.Tab.2.left/70.23.2490.1417@70.23.2490.1417" timestamp="1599100319942" />
<state width="1322" height="440" key="GridCell.Tab.2.right" timestamp="1599100319942">
<state width="1322" height="302" key="GridCell.Tab.2.left/70.23.2490.1417@70.23.2490.1417" timestamp="1599120743140" />
<state width="1322" height="302" key="GridCell.Tab.2.right" timestamp="1599120743140">
<screen x="70" y="23" width="2490" height="1417" />
</state>
<state width="840" height="374" key="GridCell.Tab.2.right/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358070" />
@@ -261,8 +267,8 @@
<state width="849" height="374" key="GridCell.Tab.2.right/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992588" />
<state width="840" height="374" key="GridCell.Tab.2.right/67.23.1725.1097@67.23.1725.1097" timestamp="1598947305945" />
<state width="1300" height="374" key="GridCell.Tab.2.right/70.23.1722.1097@70.23.1722.1097" timestamp="1598931659636" />
<state width="1322" height="440" key="GridCell.Tab.2.right/70.23.2490.1417@70.23.2490.1417" timestamp="1599100319942" />
<state width="1322" height="440" key="GridCell.Tab.3.bottom" timestamp="1599100319943">
<state width="1322" height="302" key="GridCell.Tab.2.right/70.23.2490.1417@70.23.2490.1417" timestamp="1599120743140" />
<state width="1322" height="302" key="GridCell.Tab.3.bottom" timestamp="1599120743141">
<screen x="70" y="23" width="2490" height="1417" />
</state>
<state width="840" height="374" key="GridCell.Tab.3.bottom/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358072" />
@@ -273,8 +279,8 @@
<state width="849" height="374" key="GridCell.Tab.3.bottom/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992588" />
<state width="840" height="374" key="GridCell.Tab.3.bottom/67.23.1725.1097@67.23.1725.1097" timestamp="1598947305946" />
<state width="1300" height="374" key="GridCell.Tab.3.bottom/70.23.1722.1097@70.23.1722.1097" timestamp="1598931659637" />
<state width="1322" height="440" key="GridCell.Tab.3.bottom/70.23.2490.1417@70.23.2490.1417" timestamp="1599100319943" />
<state width="1322" height="440" key="GridCell.Tab.3.center" timestamp="1599100319943">
<state width="1322" height="302" key="GridCell.Tab.3.bottom/70.23.2490.1417@70.23.2490.1417" timestamp="1599120743141" />
<state width="1322" height="302" key="GridCell.Tab.3.center" timestamp="1599120743141">
<screen x="70" y="23" width="2490" height="1417" />
</state>
<state width="840" height="374" key="GridCell.Tab.3.center/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358071" />
@@ -285,8 +291,8 @@
<state width="849" height="374" key="GridCell.Tab.3.center/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992588" />
<state width="840" height="374" key="GridCell.Tab.3.center/67.23.1725.1097@67.23.1725.1097" timestamp="1598947305945" />
<state width="1300" height="374" key="GridCell.Tab.3.center/70.23.1722.1097@70.23.1722.1097" timestamp="1598931659637" />
<state width="1322" height="440" key="GridCell.Tab.3.center/70.23.2490.1417@70.23.2490.1417" timestamp="1599100319943" />
<state width="1322" height="440" key="GridCell.Tab.3.left" timestamp="1599100319943">
<state width="1322" height="302" key="GridCell.Tab.3.center/70.23.2490.1417@70.23.2490.1417" timestamp="1599120743141" />
<state width="1322" height="302" key="GridCell.Tab.3.left" timestamp="1599120743141">
<screen x="70" y="23" width="2490" height="1417" />
</state>
<state width="840" height="374" key="GridCell.Tab.3.left/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358071" />
@@ -297,8 +303,8 @@
<state width="849" height="374" key="GridCell.Tab.3.left/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992588" />
<state width="840" height="374" key="GridCell.Tab.3.left/67.23.1725.1097@67.23.1725.1097" timestamp="1598947305945" />
<state width="1300" height="374" key="GridCell.Tab.3.left/70.23.1722.1097@70.23.1722.1097" timestamp="1598931659637" />
<state width="1322" height="440" key="GridCell.Tab.3.left/70.23.2490.1417@70.23.2490.1417" timestamp="1599100319943" />
<state width="1322" height="440" key="GridCell.Tab.3.right" timestamp="1599100319943">
<state width="1322" height="302" key="GridCell.Tab.3.left/70.23.2490.1417@70.23.2490.1417" timestamp="1599120743141" />
<state width="1322" height="302" key="GridCell.Tab.3.right" timestamp="1599120743141">
<screen x="70" y="23" width="2490" height="1417" />
</state>
<state width="840" height="374" key="GridCell.Tab.3.right/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358072" />
@@ -309,7 +315,7 @@
<state width="849" height="374" key="GridCell.Tab.3.right/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992588" />
<state width="840" height="374" key="GridCell.Tab.3.right/67.23.1725.1097@67.23.1725.1097" timestamp="1598947305946" />
<state width="1300" height="374" key="GridCell.Tab.3.right/70.23.1722.1097@70.23.1722.1097" timestamp="1598931659637" />
<state width="1322" height="440" key="GridCell.Tab.3.right/70.23.2490.1417@70.23.2490.1417" timestamp="1599100319943" />
<state width="1322" height="302" key="GridCell.Tab.3.right/70.23.2490.1417@70.23.2490.1417" timestamp="1599120743141" />
<state x="161" y="268" width="670" height="676" key="search.everywhere.popup" timestamp="1598787117227">
<screen x="53" y="23" width="1739" height="1097" />
</state>

View File

@@ -139,7 +139,6 @@ async function parseSub(sub, platform) {
$.write(raw, `#${key}`);
} else {
raw = cache;
console.log(`Cache hit`);
}
} else {
// always download from url
@@ -198,16 +197,19 @@ async function parseSub(sub, platform) {
for (const item of sub.process || []) {
// process script
if (item.type.indexOf("Script") !== -1) {
if (item.args && item.args[0].indexOf("http") !== -1) {
// if this is remote script
item.args[0] = await $.http
.get(item.args[0])
const {mode, content} = item.args;
if (mode === "link") {
// if this is remote script, download it
item.args = await $.http
.get(content)
.then((resp) => resp.body)
.catch((err) => {
throw new Error(
`Error when downloading remote script: ${item.args[0]}.\n Reason: ${err}`
`Error when downloading remote script: ${item.args.content}.\n Reason: ${err}`
);
});
} else {
item.args = content;
}
}
if (item.type.indexOf("Filter") !== -1) {
@@ -1854,6 +1856,7 @@ function ScriptOperator(script) {
return {
name: "Script Operator",
func: (proxies) => {
let output = proxies;
(function () {
// interface to get internal operators
const $get = (name, args) => {
@@ -1865,8 +1868,9 @@ function ScriptOperator(script) {
}
};
eval(script);
return func(proxies);
output = operator(proxies);
})();
return output;
},
};
}
@@ -1968,6 +1972,7 @@ function ScriptFilter(script) {
return {
name: "Script Filter",
func: (proxies) => {
let output = FULL(proxies.length, true);
!(function () {
// interface to get internal filters
const $get = (name, args) => {
@@ -1979,8 +1984,9 @@ function ScriptFilter(script) {
}
};
eval(script);
return func(proxies);
output = filter(proxies);
})();
return output;
},
};
}