title: Running tensorflow in Chrome extension
body: <p>I am having problem with implementing pretrained tensorflow.js toxicity model in my chrome extension, I used webpack to bundle my node modules.</p>
  <p><strong>The error i am getting</strong></p>
  <pre><code>popup.html:1 Unchecked runtime.lastError: Cannot access contents of the page. Extension manifest must request permission to access the respective host.
  
  engine.js:443 Uncaught (in promise) Error: No backend found in registry.
      at Engine.getSortedBackends (engine.js:443)
      at Engine.initializeBackendsAndReturnBest (engine.js:454)
      at Engine.get (engine.js:1405)
      at Engine.makeTensor (engine.js:860)
      at makeTensor (tensor_ops.js:121)
      at tensor (tensor_ops.js:80)
      at Module.decodeWeights (io_utils.js:308)
      at GraphModel.loadSync (graph_model.js:165)
      at GraphModel._callee$ (graph_model.js:129)
      at tryCatch (runtime.js:68)
  </code></pre>
  <p><em>I tried fixing the backend error via this solution, but it leads into another error <a href="https://stackoverflow.com/questions/62134812/handpose-tfjs-error-no-backend-found-in-registry">Handpose tfjs Error - No backend found in registry</a></em></p>
  <p><strong>My manifest.json</strong></p>
  <pre><code>    {
      &quot;name&quot;: &quot;TensorFlow toxicity recognition&quot;,
      &quot;version&quot;: &quot;0.1&quot;,
      &quot;description&quot;: &quot;TensorFlow chrome extension analyzing text toxicity&quot;,
      &quot;author&quot;: &quot;Petr Kolouch&quot;,
      &quot;browser_action&quot;: {
        &quot;default_popup&quot;: &quot;popup.html&quot;
    },
      &quot;permissions&quot;: [
        &quot;activeTab&quot;
      ],
      &quot;options_page&quot;: &quot;popup.html&quot;,
      &quot;content_security_policy&quot;: &quot;script-src 'self' 'unsafe-eval'; object-src 'self'&quot;,
      &quot;manifest_version&quot;: 2
    }
  </code></pre>
  <p><strong>My index.js</strong></p>
  <pre><code>const toxicity = require('@tensorflow-models/toxicity');
         
      const threshold = 0.9;
      
      chrome.tabs.executeScript( {
          code: &quot;window.getSelection().toString();&quot;
      }, (selection) =&gt; {
      
      toxicity.load(threshold).then(model =&gt; {
      
        model.classify(selection).then(predictions =&gt; {
      
          console.log(predictions);
          document.getElementById(&quot;results&quot;).innerHTML = predictions;
      
              });
          });
      });
      
  </code></pre>
  <p><strong>My popup.html</strong></p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang=&quot;en&quot;&gt;
  &lt;head&gt;
      &lt;script src=&quot;main.js&quot;&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
      &lt;div id=&quot;results&quot;&gt;
  
      &lt;/div&gt;
      
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p><strong>My webpack.config.js</strong></p>
  <pre><code>const path = require('path');
  module.exports = {
    mode: 'development',
    target: 'web',
    entry: ['babel-polyfill', './src/index.js'],
    output: {
      path: path.resolve(__dirname, 'dist'),
      filename: 'main.js'
    },
    module: {
      rules: [
        {
          use: {
            loader: 'babel-loader',
            options: {
              presets: ['@babel/preset-env'],
              plugins: ['@babel/plugin-proposal-class-properties']
            }
          }
        }
      ]
    }
  };
  </code></pre>
  <p><strong>My package.json</strong></p>
  <pre><code>{
    &quot;name&quot;: &quot;tfjsdemo&quot;,
    &quot;version&quot;: &quot;1.0.0&quot;,
    &quot;description&quot;: &quot;&quot;,
    &quot;main&quot;: &quot;index.js&quot;,
      &quot;mode&quot;: &quot;development&quot;,
      &quot;scripts&quot;: {
        &quot;build&quot;: &quot;webpack --config webpack.config.js&quot;
      },
    &quot;keywords&quot;: [],
    &quot;author&quot;: &quot;&quot;,
    &quot;license&quot;: &quot;ISC&quot;,
    &quot;devDependencies&quot;: {
      &quot;@babel/core&quot;: &quot;^7.10.3&quot;,
      &quot;@babel/plugin-proposal-class-properties&quot;: &quot;^7.10.1&quot;,
      &quot;@babel/preset-env&quot;: &quot;^7.10.3&quot;,
      &quot;babel-loader&quot;: &quot;^8.1.0&quot;,
      &quot;babel-polyfill&quot;: &quot;^6.26.0&quot;,
      &quot;webpack&quot;: &quot;^4.43.0&quot;,
      &quot;webpack-cli&quot;: &quot;^3.3.12&quot;
    },
    &quot;dependencies&quot;: {
      &quot;@tensorflow-models/toxicity&quot;: &quot;^1.2.2&quot;,
      &quot;@tensorflow/tfjs&quot;: &quot;^2.0.1&quot;
    }
  }
  </code></pre>
  <p><strong>Thanks for your help!</strong></p>