Chrome扩展声明权限混淆
Chrome Extension Declare Permissions confusion
为高对比度设置指定键盘快捷键的简单扩展,以便在不经过菜单的情况下进行切换。问题:下面的代码正在生成此错误
ChromeSetting.get:您无权访问首选项"highContrast"。请确保在清单中声明您需要的权限。
API简介https://developer.chrome.com/extensions/accessibilityFeatures#property-highContrast说要声明accessibilityFeatures.modify
和accessibilityFeatures.read
,我已经这样做了,但是这两个权限都不在声明的权限列表中https://developer.chrome.com/extensions/declare_permissions所以我不知道从这里到哪里去。。。
manifest.json
{
"name": "High Contrast Shortcut",
"description": "Press Ctrl+Shift+Y to send an event.",
"version": "1.0",
"default_locale": "en",
"manifest_version": 2,
"background": {
"scripts": ["src/bg/background.js"],
"persistent": true
},
"permissions": [
"accessibilityFeatures.read",
"accessibilityFeatures.modify"
],
"commands": {
"toggle-feature": {
"suggested_key": { "default": "Ctrl+Shift+Y" },
"description": "Send a 'toggle-feature' event to the extension"
}
}
}
background.js
chrome.commands.onCommand.addListener(function(command) {
if (command == "toggle-feature") {
var value = chrome.accessibilityFeatures.highContrast.get({'incognito': false}, function (callback) {
console.log(callback);
});
}
});
"accessibilityFeatures.read"
和"accessibilityFeatures.modify"
目前仅在Chrome操作系统中受支持,而在其他操作系统中不受支持,如中所示https://chromium.googlesource.com/chromium/src/+/7c61e0145f3e598ae7a9acc9159234d6ec7f6008/chrome/common/extensions/api/''permission_features.json:
"accessibilityFeatures.modify": {
"channel": "stable",
"extension_types": ["extension", "platform_app"],
"platforms": ["chromeos"]
},
"accessibilityFeatures.read": {
"channel": "stable",
"extension_types": ["extension", "platform_app"],
"platforms": ["chromeos"]
},
相关文章:
- Dojo不解析自定义小部件的模板html中的小部件声明性
- 直接在函数声明上使用function.prototype.bind
- 在流星上使用微信js-sdk时出现拒绝权限错误
- 获取HTML属性中CSS声明的值
- 从选项页面更新chrome扩展清单权限
- 对API数据使用声明性绑定
- 从应用程序脚本检查谷歌网站访问权限
- 在Nodejs中Express输入DEBUG=app时权限被拒绝/bin
- 如何使用Javascript客户端对象模型检索Sharepoint 2010列表项权限
- 可以Resharper在我的javascript函数声明中添加分号
- 如何为排除无穷大和NaN的数字声明Flow类型
- 此行是否包含函数声明
- Javascript以不同的方式声明数字
- 如何使用php文件中的GET来获取我在.js文件中声明的变量
- 使用同一对象中的其他变量声明变量
- 如何在AngularJS工厂中正确声明对象属性
- 用||声明变量
- 为什么在中声明具有外部访问权限的变量
- Chrome扩展声明权限混淆
- 主干视图的声明性授权(权限)