javascript - 使用代理对象覆盖 Chrome 存储 API
问题描述
当使用 JavaScript 代理调用 Chrome 存储 API 时,如何覆盖chrome.storage.local.get
以记录存储密钥的值
这是我尝试过的:
const api = chrome.storage.local;
const { set } = api;
api.set = new Proxy(api.set, {
apply: (target, thisArg, argumentsList) => {
console.log(argumentsList[0]);
return target(argumentsList[0]);
}
});
被调用Illegal invocation: Function must be called on an object of type StorageArea
时出现错误target(argumentsList[0])
解决方案
推荐阅读
- c# - 对 AZ、0-9、- 和点使用正则表达式?
- mysql - mysql order by 从不同的表打破排名
- java - 如何在骡子的https请求中设置标头
- python - 子类化时允许嵌套返回类型的协方差
- spring-boot - 如果两条路线几乎相同,弹簧靴的行为是什么?
- swift - 如何从 Swift 中的 NSTokenAttachmentCell 继承?
- python - xlwings 中的图表对象
- xaml - UWP/C# ItemsControl 多个框?
- r - 如何在数据框中划分列和以下内容
- shopify - 尝试使用 GET 请求从本地主机访问 Shopify api