[英]Update chrome extension manifest permissions from options page
I am trying to update the permissions in the chrome extension manifest file from the options page. 我正在尝试从选项页面更新chrome扩展清单文件中的权限。 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.
基本上,用户应该能够输入要运行的扩展的URL,并且该URL将在扩展清单文件中更新。 I am currently storing all my options using chrome.storage.sync for use in multiple files.
我目前正在使用chrome.storage.sync存储我的所有选项,以便在多个文件中使用。 I am looking for a secure solution to give only the chosen url access.
我正在寻找一个安全的解决方案,只给出选择的URL访问权限。 Any suggestions?
有什么建议么?
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. 在这种情况下,
"activeTab"
权限和Programmatic Injection应该可以解决您的问题。
chrome.storage
. chrome.storage
。 "activeTab"
permission). "activeTab"
权限)。
chrome.tabs.executeScript
to inject your content script. chrome.tabs.executeScript
注入您的内容脚本。 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 . 或者,您可以查看Optional Permissions API 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.