Can I make two branch decision in webRequest.onBeforeRequest

If I am using webRequest.onBeforeRequest to intercept URLs that match certain patterns. If a match is found, the callback function is called and it performs somethings before the request is sent.

If no match is found, I want to do other things before the request is sent and these other things needs to be performed before each other request that has not been matched (i.e. not one-time task but needs to be done repeatedly after each check).

Is this ever possible? I can only see a way to do things when a match is found, but not when no match is found.

This is a sample code for doing something when a match is found. How can I add: when no match is found, do this task (for each examined request before the request is sent).

p=["https://*.yahoo.com/*"];

function logURL(requestDetails)
{
    console.log("inside logURL");
    console.log("*******************************");
    console.log("Loading: " + requestDetails.url);
    console.log("*******************************");
}//end logUTL

browser.webRequest.onBeforeRequest.addListener(
  logURL,
  {urls: [p],
   types: ["main_frame"]}
);

Just subscribe without filter and do the matching yourself.

To elaborate on Nilkas’s answer, specify <all_urls> when adding the listener, then perform your own URL pattern matching in logURL().