Spaces:
Running
Running
Download webui/js/html-links.js from Leon4gr45/openoperator: direct link, hf CLI and curl.
- Browser
- Download file 777 Bytes
-
https://huggingface.co/spaces/Leon4gr45/openoperator/resolve/main/webui/js/html-links.js
- Command line
-
hf download hf://spaces/Leon4gr45/openoperator/webui/js/html-links.js
-
curl -L -o html-links.js https://huggingface.co/spaces/Leon4gr45/openoperator/resolve/main/webui/js/html-links.js
777 Bytes
| export function addBlankTargetsToLinks(str) { | |
| const doc = new DOMParser().parseFromString(str, "text/html"); | |
| doc.querySelectorAll("a").forEach((anchor) => { | |
| const href = anchor.getAttribute("href") || ""; | |
| if ( | |
| href.startsWith("#") || | |
| href.trim().toLowerCase().startsWith("javascript") | |
| ) { | |
| return; | |
| } | |
| if ( | |
| !anchor.hasAttribute("target") || | |
| anchor.getAttribute("target") === "" | |
| ) { | |
| anchor.setAttribute("target", "_blank"); | |
| } | |
| const rel = (anchor.getAttribute("rel") || "").split(/\s+/).filter(Boolean); | |
| if (!rel.includes("noopener")) rel.push("noopener"); | |
| if (!rel.includes("noreferrer")) rel.push("noreferrer"); | |
| anchor.setAttribute("rel", rel.join(" ")); | |
| }); | |
| return doc.body.innerHTML; | |
| } | |