Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get permission to access my own extensions resources (a specific page)?

Due to recent changes in the Chrome API, my plugin issues this error:

Error during tabs.executeScript: Cannot access contents of url "chrome-extension://ecfgljdfndkhhbmhcnelbpnhkflgiokp/cm_signature_editor.html". Extension manifest must request permission to access this host.

This never used to be the case. Now I wonder how I get the URL of the chrome extension into it's manifest file:

I know I can get the url or a resource within my extension like so:

chrome.extension.getURL('/manifest.json')

But I don't know how that can work in the manifest file.

Is there another way to get this code working?

chrome.tabs.executeScript(null, {code:function_to_execute}, function() {
    // callback
});

What's interesting is that even when I hardcode the chrome URL it doesn't work (I get the same error)

"permissions" : [
    "tabs",
    "contextMenus",
    "chrome-extension://ecfgljdfndkhhbmhcnelbpnhkflgiokp/*"
  ],
like image 725
Victor S Avatar asked Apr 02 '12 16:04

Victor S


2 Answers

I think you cant inject a script in a extension page in that way. You should incorporate the script in the page just by writing it in you extension HTML file. And make comunications between extension pages using chrome.extension.sendRequest and chrome.extension.onRequest

like image 145
Alejandro Silvestri Avatar answered Oct 13 '22 00:10

Alejandro Silvestri


Using chrome.extension.getViews() may be helpful.

like image 36
riophae Avatar answered Oct 12 '22 23:10

riophae