()
| 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 | } |
no test coverage detected