google chrome extension - chome.tabs.executeScript from external file? What permissions do I need to change in manifest.json? -
i'd run chrome.tabs.executescript run file stored on remote server (for testing purposes, server localhost). here code have far:
chrome.tabs.executescript(tabid, {file: 'http://localhost/js/mytestfile.js'}, function() { //do stuff on completion });
i know default, programmatically injected content scripts cannot sourced remote location, can "whitelist" sources in manifest change that. here manifest @ moment:
//extensions permissions "permissions": [ "activetab", "notifications", ], //external access permissions "externally_connectable": { "matches": [ "http://localhost/*", ] } //directories available extension "web_accessible_resources": [ "js/*", "html/*", "img/*" ], "content_scripts": [ { "matches": ["<all_urls>"], "js": ["js/lib/require-2.1.8.min.js", "js/extension/contentmanager.js"], "all_frames": true } ],
in way can modify manifest allow remote js file injected content script?
you need ask "tabs" permissions inject script page. note can inject code or link script. there may issue injecting remote script, can pull down js , inject directly page.
to include remote script background page, need list domain in content_security_policy , must https unless on localhost.
Comments
Post a Comment