(tabId, allFrames, frameId, css, monkey)
| 290 | }; |
| 291 | |
| 292 | const _injectCss = (tabId, allFrames, frameId, css, monkey) => { |
| 293 | try { |
| 294 | chrome.scripting.insertCSS({ |
| 295 | target: _buildTarget(tabId, allFrames, frameId), |
| 296 | css |
| 297 | }).catch((err) => { |
| 298 | log({ |
| 299 | id: monkey && monkey.id, name: (monkey && monkey.mName) || '', level: 'error', |
| 300 | msg: 'css inject failed: ' + ((err && err.message) || err), |
| 301 | url: '(tab ' + tabId + ')', time: Date.now() |
| 302 | }); |
| 303 | }); |
| 304 | } catch (e) { |
| 305 | log({ |
| 306 | id: monkey && monkey.id, name: (monkey && monkey.mName) || '', level: 'error', |
| 307 | msg: 'css inject failed: ' + ((e && e.message) || e), |
| 308 | url: '(tab ' + tabId + ')', time: Date.now() |
| 309 | }); |
| 310 | } |
| 311 | }; |
| 312 | |
| 313 | // MAIN world 没有 chrome.runtime,需要在 ISOLATED world 中常驻一个桥接监听器, |
| 314 | // 通过 window.postMessage 接收 MAIN world 抛出的日志,再转发到 background。 |
no test coverage detected