chromiumoxide/javascript/
extract.rs

1pub(crate) const OUTER_HTML: &str = r###"{let rv = ''; if(document.doctype){rv+=new XMLSerializer().serializeToString(document.doctype);} if(document.documentElement){rv+=document.documentElement.outerHTML;} rv}"###;
2/// XML serializer for custom pages or testing.
3pub(crate) const FULL_XML_SERIALIZER_JS: &str = "(()=>{let e=document.querySelector('#webkit-xml-viewer-source-xml');let x=e?e.innerHTML:new XMLSerializer().serializeToString(document);return x.startsWith('<?xml')?x:'<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n'+x})()";
4
5/// Generate a marker at the click position. Useful for older chrome versions.
6pub(crate) fn generate_marker_js(x: f64, y: f64) -> String {
7    format!(
8        "(()=>{{const m=document.createElement('div');m.style='position:absolute;left:{}px;top:{}px;width:10px;height:10px;background:hsl('+Math.floor(Math.random()*360)+',100%,50%);border:2px solid white;border-radius:50%;z-index:9999;pointer-events:none';document.body.appendChild(m);}})();",
9        x - 5.0,
10        y - 5.0
11    )
12}