use wasm_bindgen::JsCast;
use web_sys::Element;
pub(crate) fn replace_head(new: &str) {
let document = web_sys::window().unwrap().document().unwrap();
let head_node = document.query_selector("head").unwrap().unwrap();
let head_elem: Element = head_node.unchecked_into();
let els_to_remove = document
.query_selector_all(r#"meta[itemprop='__perseus_head_boundary'] ~ *"#)
.unwrap();
for idx in 0..(els_to_remove.length()) {
let el = els_to_remove.get(idx).unwrap();
head_elem.remove_child(&el).unwrap();
}
head_elem.insert_adjacent_html("beforeend", new).unwrap();
}