KangoExtensions / kango

Kango framework issue tracker
74 stars 7 forks source link

Can't declare a match pattern permission in Chrome #87

Closed hartleybrody closed 10 years ago

hartleybrody commented 10 years ago

The extension I'm building only needs to run the content script on a few domains. It shouldn't have to request the https://*/* and http://*/* permissions which tell the user it can access data on "All Websites" on the install confirmation pop-down.

I'd be happy with a chrome-only solution, but there doesn't appear to be a way to specify that I'd like to only have certain match patterns in the permissions, not all sites. Any tips?

hartleybrody commented 10 years ago

Got it working by doing a monkeypatch :monkey_face: In kango/builders/chrome.py, on line 128, the code checks to see if the info.permissions["content_scripts"] list from the extension_info.json file is different from the default of ["https://*/*", "http://*/*"]. I added some lines to not only update the content scripts matches part of the manifest, but also the permissions part of the manifest.

Basically, changing this

if info.permissions['content_scripts'] != self.DEFAULT_CONTENT_SCRIPTS_MATCHES:
    manifest['content_scripts'][0]['matches'] = info.permissions['content_scripts']

to

if info.permissions['content_scripts'] != self.DEFAULT_CONTENT_SCRIPTS_MATCHES:
    manifest['content_scripts'][0]['matches'] = info.permissions['content_scripts']
    manifest['permissions'].remove("http://*/*")
    manifest['permissions'].remove("https://*/*")
    manifest['permissions'].extend(info.permissions['content_scripts'])
akrylysov commented 10 years ago

Please try to use permissions.xhr. extenssion_info.json example:

{
    "permissions": {
        "content_scripts": ["http://www.blogger.com/"],
        "xhr": ["http://www.blogger.com/"]
    }
}