In MV3 I want to use webRequestBlocking when it is available, but if not then I want to just use regular webRequest.
I could use chrome.permissions.contains to check for webRequestBlocking, then register the listener as blocking or not depending on the asynchronous result of the chrome.permissions.contains call. But that won't register the listener at the first run so as I understand it the first event that awoke the SW might be missed?
The only solution I could think of was to make two calls to webRequest.onBeforeRequest.addListener, one requesting blocking, the other not requesting blocking. Then call chrome.permissions.contains and if the blocking permission is available, remove the non-blocking listener.
Then I have to deal with both listeners potentially being called until I get the response from chrome.permissions.contains.
Am I missing something? Is there an easier approach?