javascript - Can I use Programmatic Injection on the popup HTML page of a chrome extension? -
as title suggests trying use content script or other means of programatic injection manipulate website displayed within iframe, located within popup html file of chrome extension. src of iframe 3rd party website.
the way typically execute content script background page of chrome extension follows:
//background.js chrome.contextmenus.create({ title: "xxx", contexts:["page"], id: "ctx1" }); chrome.contextmenus.onclicked.addlistener(function(info,tab) { if(infoitemid === "ctx1"){ console.log("control worked") control(info,tab) } }); function control(info,tab) { chrome.tabs.executescript(tab.id,{file:"content.js"}); } or
chrome.tabs.onupdated.addlistener(function(tabid, changeinfo, tab) { alert(json.stringify(tab) +"\n\n") chrome.tabs.executescript(null,{"file":"content.js"}); }) i can access iframe background page following code:
var views = chrome.extension.getviews({type:'popup'}); var iframe = views[0].document.getelementbyid("frame1") // "frame1" id id of iframe html element declared in popup.html file i unsure how reconfigure background page iframe in popup.html page targeted instead of active browser tab. thinking need change "contexts" attribute of context menu "frames" or "browser_action" , may need create new tab same url popup.html file. have spent long time working on problem , have made virtually 0 progress, appreciated.
Comments
Post a Comment