title: Chrome Extension: webRequest Redirect to Existing Tab, Without Opening New Tab
body: <p>When a user opens a certain page, I want to open that page in an existing tab, before a new tab is opened. I've tried with webRequest:</p>
  
  <pre><code>chrome.webRequest.onBeforeRequest.addListener(
      function(details) {
          chrome.tabs.query({ url: 'https://example.com/' },function (tabs) {
              chrome.tabs.update(tabs[0].id, { url: details.url, highlighted: true });
          })
      },
      {urls: ['https://example.com/']},
      ['blocking']
  );
  </code></pre>
  
  <p>I've also tried with webNavigation:</p>
  
  <pre><code>chrome.webNavigation.onBeforeNavigate.addListener(function (details) {
      if(details.url=="https://example.com/") {
          chrome.tabs.query({ url: 'https://example.com/' },function (tabs) {
              chrome.tabs.update(tabs[0].id, { url: details.url, highlighted: true });
          });
      }
  });
  </code></pre>
  
  <p>Both of these open a new tab that has to be closed, and it causes the browser to jump around between tabs.</p>
  
  <p>Is there any way to intercept requests before a new tab is opened?</p>
  
  <p>Thanks!</p>