javascript - 无法使用 chrome.declarativeNetRequest.updateDynamicRules() 更新规则
问题描述
这是我的“popup.js”代码,我试图通过按下扩展弹出窗口中的保存按钮来添加动态规则,但 webstorm 指示此规则数组不是 Rule [] 类型。忽略 Webstorm 并尝试使用它我得到这个错误有Unchecked runtime.lastError: Internal error while updating dynamic rules.
什么想法吗?
const saveButton = document.getElementById("save")
saveButton.addEventListener('click',() => {
console.log(document.getElementById('domain').value)
chrome.declarativeNetRequest.updateDynamicRules(
{
addRules: [
{
"id": 1,
"priority": 1,
"action": {
"type": "redirect",
"redirect": {
"regexSubstitution": document.getElementById('domain').value
}
},
"condition": {
"regexFilter": "www.youtube.com",
"resourceTypes": [
"main_frame"
],
"excludedDomains": [document.getElementById('domain').value]
}
}
]
}
)
})
解决方案
推荐阅读
- java - Selenium XPaths 中的魔法命名空间前缀
- python-3.x - 针对特定方法从另一个安装目录导入包
- java - Windows中的Java FileSystemPreferencesFactory
- javascript - 获取悬停时样式属性更改的元素列表
- c++ - c++17通过生成预先声明的类型列表的笛卡尔积来制作std::variant
- javascript - GraphQL 错误:$completedAt 的默认值与 React Apollo 中的 DateTime 类型不匹配?
- mysql - 如何在“推荐列”中获取“用户 ID”的计数
- android - 如何从 Prod 构建风格中删除库?
- css - 为什么`minmax`总是使用最大空间?
- pug - 您可以在不使用扩展的情况下在哈巴狗中嵌套标签吗?