Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/theberrigan/rust-wasm-chrome-ext
Simple example of Chrome extension (with manifest v3) using Rust compiled to Wasm
https://github.com/theberrigan/rust-wasm-chrome-ext
chrome extension-chrome manifest-v3 rust wasm wasm-pack web-assembly
Last synced: 3 months ago
JSON representation
Simple example of Chrome extension (with manifest v3) using Rust compiled to Wasm
- Host: GitHub
- URL: https://github.com/theberrigan/rust-wasm-chrome-ext
- Owner: theberrigan
- Created: 2023-06-02T15:57:07.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-10-22T15:01:47.000Z (3 months ago)
- Last Synced: 2024-11-02T13:20:15.160Z (3 months ago)
- Topics: chrome, extension-chrome, manifest-v3, rust, wasm, wasm-pack, web-assembly
- Language: JavaScript
- Homepage:
- Size: 13.7 KB
- Stars: 12
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Rust Web Assembly Chrome Extension Example
## Setup
1. Install [wasm-pack](https://rustwasm.github.io/wasm-pack/installer/):```
cargo install wasm-pack
```
2. Go to ```/wasm_mod``` and run ```build.bat```.
It will compile the ```.wasm``` module and ```.js```-wrapper for it and put them in the ```extension/js/wasm```
3. Go to Chrome extensions page and load unpacked extension from ```/extension```## Notes
- ```extension/js/content.js``` demonstrates how to load wasm into the content script
**Important:** in the content script, the module can only be loaded for those sites whose Content Security Policy does not prohibit it
- ```extension/js/background.js``` demonstrates how to load wasm into the background worker script
- For ```wasm-pack``` always use ```--target web```
- ```manifest.json```:
- To load the wasm module into the content script, you should list ```.wasm``` and corresponding ```.js``` in the ```web_accessible_resources.resources``` section of manifest
- To load the wasm module into the background worker script, you should specify ```wasm-unsafe-eval``` in the ```content_security_policy.extension_pages``` section of manifest## Tested with
- Chrome 114 (extension manifest v3)
- Rust 1.70 (edition 2021)
- wasm-bindgen 0.2.86
- wasm-pack 0.11.1