Sunday, 25 August 2019

Use Wasm in content script of a web extension

I am building a firefox addon and I am using rust. I am trying to insert html and do stuff on specific pages.

Apparently content script is the thing I want to use. My content script is:

import("../crate/pkg").then(({ Addon }) => {
    const addon = Addon.new();

    console.log(addon.where_am_i());
}).catch(e => console.error("Error importing:", e));


The error I am getting is:

TypeError: "0125c9960050e7483877.module.wasm is not a valid URL."

I tried to add to manifest.json:

"web_accessible_resources": [
  "0125c9960050e7483877.module.wasm"
]

and access it as moz-extension://<extension-UUID>/0125c9960050e7483877.module.wasm" but then I got:

Error importing: Error: "Loading chunk 0 failed.

I also tried background script, but that is loaded in extension context, so that doesn't allow me to alter page content.



from Use Wasm in content script of a web extension

No comments:

Post a Comment