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

Function _execJs

apps/background/inject-tools.js:20–37  ·  view source on GitHub ↗
(tabId, allFrames, js, callback, world)

Source from the content-addressed store, hash-verified

18 };
19
20 let _execJs = (tabId, allFrames, js, callback, world) => {
21 let opts = {
22 target: {tabId, allFrames},
23 func: function(code){
24 try {
25 new Function('window', 'document', 'globalThis', 'self', code)(window, document, window, window);
26 } catch (e) {}
27 },
28 args: [js]
29 };
30 if (world) opts.world = world;
31 chrome.scripting.executeScript(opts, function () {
32 if (chrome.runtime.lastError) {
33 console.warn('InjectTools._execJs failed:', chrome.runtime.lastError);
34 }
35 callback && callback.apply(this, arguments);
36 });
37 };
38
39 /**
40 * 如果tabId指定的tab还存在,就正常注入脚本

Callers 1

injectScriptIfTabExistsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected