Reputation: 31
I am trying to update the permissions in the chrome extension manifest file from the options page. Basically the user should be able to input the url for the extension to run on and that url will update in the extensions manifest file. I am currently storing all my options using chrome.storage.sync for use in multiple files. I am looking for a secure solution to give only the chosen url access. Any suggestions?
Upvotes: 3
Views: 1180
Reputation: 77591
That's not possible (to update the manifest).
However, the particular use case you explain is:
In this case "activeTab"
permission and Programmatic Injection should solve your problem.
chrome.storage
."activeTab"
permission).
chrome.tabs.executeScript
to inject your content script.Here's some sample code:
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
var currentTab = tabs[0];
// Pseudocode
if (whitelisted(currentTab.url)) {
chrome.tabs.executeScript(currentTab.id, {file: "content.js"});
} else {
// Do nothing or show some warning
}
});
Alternatively, you can look at Optional Permissions API.
Upvotes: 1