title: Chrome extension forwards blocked sites to html page, but only when the link is written directly in the search bar
body: <p>I'm making a simple Chrome extension for a project, but I have one odd issue.
  I've made a site blocker in the background script:</p>
  <pre><code>    localStorage.setItem('blocked_sites',  [&quot;*://www.wikipedia.org/*&quot;, &quot;*://www.change.org/*&quot;, &quot;*://en.wikipedia.org/*&quot;]); 
  urls = localStorage.getItem('blocked_sites').split(',');
  
  chrome.webRequest.onBeforeRequest.addListener(
  function(intercept) {
      console.log(intercept.url);
      localStorage.setItem('denied_access_url', intercept.url);
       return {redirectUrl: chrome.extension.getURL(&quot;chatbot.html&quot;)};
       
  },
  {
      urls,
      types: [&quot;main_frame&quot;, &quot;sub_frame&quot;, &quot;stylesheet&quot;, &quot;script&quot;, &quot;image&quot;, &quot;object&quot;, 
  &quot;xmlhttprequest&quot;, &quot;other&quot;]
  },
  [&quot;blocking&quot;]
  );
  </code></pre>
  <p>This blocker works when I directly visit a site by typing a url in the search bar. The page redirects to my html file fine. But if I google search and then click on a link or click on a hyperlink in an email, the site is blocked but the page is not redirected to 'chatbot.html', the page says:</p>
  <p>'blninlecioflbneanancablcknibdbja is blocked
  This page has been blocked by Chrome
  ERR_BLOCKED_BY_CLIENT'
  (the random letters are the name of the local extension folder, generated by chrome). The terminal says
  &quot;(index):7272 crbug/1173575, non-JS module files deprecated.
  (anonymous) @   (index):7272&quot;
  and then clicking on the number at the end of the string shows</p>
  <p>'No resource with given URL found'</p>
  <p>Oddly enough, when I print out the url in the background.js console and click it, redirection to chatbot.html works. It also works when I click on links in word documents (but again, not links in emails!).</p>
  <p>I've tried researching these errors, but haven't found much.</p>
  <p>Why can the file be found only sometimes?</p>