javascript - 如何防止 chrome 扩展在 chrome:// url 上运行
问题描述
如果我尝试在 chrome:// url 上打开 popup.html,我的 Chrome 扩展程序会引发错误。
我设置了回调函数来防止这种情况:
/ Inject the payload.js script into the current tab after the popout has loaded
window.addEventListener('load', function (evt) {
// catching injecting into chrome:// pages error
chrome.extension.getBackgroundPage().chrome.tabs.executeScript(null, {
file: 'js/payload.js'
}, ()=>{
if(chrome.runtime.lastError) {
console.log("injecting error");
}
});;
});
然而,错误仍然出现。"chrome://*/"
我的清单文件中有什么方法可以允许吗?
解决方案
推荐阅读
- reactjs - 刷新后Reactjs保存状态
- java - 该程序检查两个数组是否以某种顺序具有相同的元素
- faunadb - 如何返回 FaunaDB 中的所有非空数据?
- python - 如何从数据库中的两个表中获取最新的 N 个条目?
- c++ - 开关/外壳中的准“如果”
- node.js - 如何使用 type-graphql 解析器函数获取 graphql 后端中的选定字段?
- r - 您可以重命名 R“格式表”中的列,而不会丢失以前应用的格式吗?
- r - 来自具有“字符”的数据帧条目列表的上样
- html - 使用 XSLT 和 XPath 计算元素最大属性值失败
- c - 归并排序算法问题:不同的输出