chrome-sys 0.2.0

Raw wasm_bindgen bindings for the Chrome Browser Extension API.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use wasm_bindgen::prelude::*;

pub fn chrome_obj() -> std::result::Result<JsValue, JsValue> {
    js_sys::Reflect::get(&js_sys::global(), &"chrome".into())
}

pub fn runtime_obj() -> std::result::Result<JsValue, JsValue> {
    js_sys::Reflect::get(&chrome_obj()?, &"runtime".into())
}

pub fn runtime_id() -> std::result::Result<String, JsValue> {
    Ok(js_sys::Reflect::get(&runtime_obj()?, &"id".into())?
        .as_string()
        .unwrap())
}