3

When I try to inject an html file using .insertAdjacentHTML

fetch(chrome.runtime.getURL('inject.html')).then(r => r.text()).then(html => {
  document.body.insertAdjacentHTML('beforeend', html);
  // not using innerHTML as it would break js event listeners of the page
});

The console returns "ERR_BLOCKED_BY_CLIENT"

ERR_BLOCKED_BY_CLIENT error message

I have it in web-accessible resources (Manifest version 3)

"web_accessible_resources": [
      {
        "resources": [ "inject.html" ],
        "matches": [ "<all_urls>" ]
      }
    ],

I'm testing it on my own site with a simple text form. I disabled all other chrome extensions and reloaded the page, and still, the error.

Here is a link to the repo:

https://github.com/fishsticks89/Latinizer/tree/main/src

Michael Barr
  • 35
  • 1
  • 6
  • 2
    1) reload the extension on chrome://extensions page, 2) use `"manifest_version":3` or switch to the [old syntax of web_accessible_resources](https://developer.chrome.com/docs/extensions/mv2/manifest/web_accessible_resources/). – wOxxOm Apr 19 '21 at 18:45
  • Both those things I have already done, although I really am considering downgrading manifest versions due to this error – Michael Barr Apr 19 '21 at 19:27
  • Since it works for other people there must be something wrong in the other parts of code or maybe inject.html is not present in the root folder of the extension. – wOxxOm Apr 20 '21 at 03:41
  • Here is my manifest: https://github.com/fishsticks89/Latinizer/blob/main/src/manifest.json and injectior.js https://github.com/fishsticks89/Latinizer/blob/main/src/injector.js along with the folder with all of the resources in it, including injector.js and inject.html https://github.com/fishsticks89/Latinizer/tree/main/src – Michael Barr Apr 20 '21 at 04:01
  • 1
    It works in Chrome 89 and newer. Note though the scripts inside inject.html won't run so it doesn't make sense to use this approach. Either include these scripts in `content_scripts` section or [use an iframe](https://stackoverflow.com/a/25100953). – wOxxOm Apr 20 '21 at 04:28

0 Answers0