MCPcopy Index your code
hub / github.com/scriptscat/scriptcat / pageLoad

Method pageLoad

src/app/service/content/scripting.ts:149–177  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

147 }
148
149 pageLoad() {
150 const client = new RuntimeClient(this.senderToExt);
151 // 向service_worker请求脚本列表及环境信息
152 client.pageLoad().then((o) => {
153 if (!o.ok) return;
154 const { injectScriptList, contentScriptList, envInfo } = o;
155 const pairs = {} as Record<string, PageOrContent>;
156 for (const script of injectScriptList) {
157 pairs[getStorageName(script)] |= PageOrContent.PAGE;
158 }
159 for (const script of contentScriptList) {
160 pairs[getStorageName(script)] |= PageOrContent.CONTENT;
161 }
162 this.activeStorageNames = new Map(Object.entries(pairs));
163
164 // 向页面 发送脚本列表及环境信息
165 if (contentScriptList.length) {
166 const contentClient = new Client(this.senderToContent, "content");
167 // 根据@inject-into content过滤脚本
168 contentClient.do("pageLoad", { scripts: contentScriptList, envInfo });
169 }
170
171 if (injectScriptList.length) {
172 const injectClient = new Client(this.senderToInject, "inject");
173 // 根据@inject-into content过滤脚本
174 injectClient.do("pageLoad", { scripts: injectScriptList, envInfo });
175 }
176 });
177 }
178}

Callers 1

scripting.tsFile · 0.45

Calls 4

pageLoadMethod · 0.95
doMethod · 0.95
getStorageNameFunction · 0.90
entriesMethod · 0.80

Tested by

no test coverage detected