Skip to content

obox-systems/demo_web_plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Browser extension

Abstract

In this project, I developed a simple Google Chrome extension that prints the URLs of all opened tabs of the browser in the extension HTML window, when the button of the extension is pressed. This extension also takes the screenshot of a selected file and displays this screenshot in the HTML window. Extension has a button to download the screenshot in the png file. This extension was written in Rust and compiled to WASM to use the Rust functions in the Javascript module of the extension later.

In this project all Rust functions are in the src folder, they perform the main logic of a plugin. manifest.json is the file with all settings of the plugin and is the first file that our browser sees after installing the plugin. popup.html is a file with HTML markup of a plugin window. In style.css there is a style for this HTML window. And the script.js file contains Javascript functions that are exported into Rust.

I used a wasm-bindgen crate to compile functions from Rust module into a wasm file. I also used a web-sys crate to get the information about the URLs of all opened tabs of the browser. With a help of the web-sys crate I also created a canvas to draw an image with the screenshot there.

With this extension, you can take a screenshot of any tab, window, or even the entire screen. It's also very easy to use.

How to run

  1. Install Rust
  2. Install Wasm-pack
cargo install wasm-pack
  1. Run the app
RUSTFLAGS=--cfg=web_sys_unstable_apis wasm-pack build --target web
  1. Open Google Chrome browser and install the extension
  2. Press the button to select the file to take screenshot

Example

Here is an example of taking a screenshot of a tab:

res

Useful links

  1. Compilation to Wasm: https://developer.mozilla.org/en-US/docs/WebAssembly/Rust_to_Wasm
  2. Creating a plugin for Chrome: https://www.freecodecamp.org/news/write-your-own-browser-extensions/
  3. Crate documentation: https://rustwasm.github.io/wasm-bindgen/introduction.html

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published