(tabId, allFrames, js, callback, world)
| 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还存在,就正常注入脚本 |
no outgoing calls
no test coverage detected