我要在webRequest API中添加一个eventListener,在其回调中,我要调用存储API来检查值。如何从存储API内部响应webRequest API?
chrome.webRequest.onBeforeRequest.addListener(
async function(details) {
console.log('from first callback');
await chrome.storage.sync.get('disabled', function (value) {
console.log('from inside of second callback');
if (value.disabled) {
console.log('returned false')
return { cancel: false } // this should return from the function (details) level
} else {
console.log('returned true')
return { cancel: true }
}
})
console.log('still from first')
},
{urls: [
"myurl"
]},
["blocking"]);
我听过一些关于诺言的事情,但是我无法弄清楚。我该如何实现?