todo: 优化加载的脚本资源保存
This commit is contained in:
parent
d7adffcd9f
commit
498d36567b
@ -196,33 +196,36 @@ export class RuntimeService {
|
|||||||
// 匹配当前页面的脚本
|
// 匹配当前页面的脚本
|
||||||
const matchScriptUuid = await this.getPageScriptUuidByUrl(chromeSender.url!);
|
const matchScriptUuid = await this.getPageScriptUuidByUrl(chromeSender.url!);
|
||||||
|
|
||||||
const scripts = await Promise.all(
|
const scripts = matchScriptUuid.map((uuid) => {
|
||||||
matchScriptUuid.map(async (uuid): Promise<undefined | ScriptRunResouce> => {
|
const scriptRes = Object.assign({}, this.scriptMatchCache?.get(uuid));
|
||||||
const scriptRes = Object.assign({}, this.scriptMatchCache?.get(uuid));
|
// 判断脚本是否开启
|
||||||
// 判断脚本是否开启
|
if (scriptRes.status === SCRIPT_STATUS_DISABLE) {
|
||||||
if (scriptRes.status === SCRIPT_STATUS_DISABLE) {
|
return undefined;
|
||||||
|
}
|
||||||
|
// 如果是iframe,判断是否允许在iframe里运行
|
||||||
|
if (chromeSender.frameId !== undefined) {
|
||||||
|
if (scriptRes.metadata.noframes) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
// 如果是iframe,判断是否允许在iframe里运行
|
}
|
||||||
if (chromeSender.frameId !== undefined) {
|
// 获取value
|
||||||
if (scriptRes.metadata.noframes) {
|
return scriptRes;
|
||||||
return undefined;
|
});
|
||||||
}
|
|
||||||
}
|
|
||||||
// 获取value
|
|
||||||
return scriptRes;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
const enableScript = scripts.filter((item) => item);
|
const enableScript = scripts.filter((item) => item);
|
||||||
|
|
||||||
// 加载value
|
await Promise.all([
|
||||||
await Promise.all(
|
// 加载value
|
||||||
enableScript.map(async (script) => {
|
...enableScript.map(async (script) => {
|
||||||
const value = await this.value.getScriptValue(script!);
|
const value = await this.value.getScriptValue(script!);
|
||||||
script!.value = value;
|
script!.value = value;
|
||||||
})
|
}),
|
||||||
);
|
// 加载resource
|
||||||
|
...enableScript.map(async (script) => {
|
||||||
|
// const resource = await this.script.buildScriptRunResource(script!);
|
||||||
|
// script!.resource = resource;
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
|
||||||
this.mq.emit("pageLoad", {
|
this.mq.emit("pageLoad", {
|
||||||
tabId: chromeSender.tab?.id,
|
tabId: chromeSender.tab?.id,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user