MCPcopy Create free account
hub / github.com/zxlie/FeHelper / _injectCss

Function _injectCss

apps/background/monkey.js:292–311  ·  view source on GitHub ↗
(tabId, allFrames, frameId, css, monkey)

Source from the content-addressed store, hash-verified

290};
291
292const _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。

Callers 1

injectMonkeyFunction · 0.85

Calls 2

_buildTargetFunction · 0.85
logFunction · 0.70

Tested by

no test coverage detected