On Jun 20, 9:16 am, Richard Harding <
rhard...@mitechie.com> wrote:
> I'm trying to find a method to trigger the popup action of my
> extension from a keyboard shortcut injected into the page via a
> content script. I can find many people using the content scripts to
> perform actions, but I can't find the necessary trick/api call to
> popup an extension.
I did see a reference to using an event to open the popup.html in a
new tab. I tried this out. Unfortunately may plugin is related to the
url of the current tab. So when I trigger the popup.html into a new
tab, the url is off.
I tried to send in the value of the previous tab url via:
chrome.extension.onRequest.addListener(
function(request, sender, sendResponse) {
if (request.url) {
chrome.tabs.getSelected(null, function(tab_obj) {
var opened_from = tab_obj;
chrome.tabs.create({url: "popup.html"},
function (tab_obj) {
var opened = opened_from.url,
title = opened_from.title;
code = "window.onload(function()
{alert('test');};";
alert('calling');
chrome.tabs.executeScript(
tab_obj.id,
{'code': code});
});
});
}
}
);
However, I get a permission issue with the executeScript since the url
scheme is chrome-extrension://
I can't add that to the permissions since it's not a valid scheme.
The idea was that I could try to inject some code that knew the url/
title of the previous page into the popup.html.
Are there any workaround to this method I might be able to keep
pursuing?
Thanks
Rick