diff --git a/app/scripts/background/main.js b/app/scripts/background/main.js index 760f665..9265c7c 100644 --- a/app/scripts/background/main.js +++ b/app/scripts/background/main.js @@ -60,14 +60,20 @@ * @param {Object} message */ 'do-script-injection': function (message) { + const frameId = message.frameId; chrome.windows.getCurrent().then(w => { chrome.tabs.query({ active: true, windowId: w.id }).then(tabs => { + const target = { + tabId: tabs[0].id + }; + // inject the script only into the frame + // specified in the request from the devTools UI5 panel script; + // If no frameId specified, the script will be injected into the main frame + if (frameId !== undefined) { + target.frameIds = [message.frameId]; + } chrome.scripting.executeScript({ - target: { - // inject the script only into the frame - // specified in the request from the devTools UI5 panel script - tabId: tabs[0].id, frameIds: [message.frameId] - }, + target, files: [message.file] }); });