Skip to content

armgit / moli

Public Imported from GitHub
0

Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust

1.5 KB
Raw Blame
<!doctype html>
<meta charset="utf-8">
<body></body>
<script>
const STORAGE_PREFIX = "__lm_wpt_form_top_level_target_keywords_basic__";
const params = new URLSearchParams(location.search);
const targetKeyword = params.get("target") ?? "_top";

function key(suffix) {
  return STORAGE_PREFIX + suffix;
}

if (targetKeyword === "_top") {
  for (const suffix of [
    "order",
    "submitCount:_top",
    "submitCount:_parent",
    "arrival:_top",
    "arrival:_parent",
    "queryTarget:_top",
    "queryTarget:_parent",
  ]) {
    sessionStorage.removeItem(key(suffix));
  }
}

const sameNamedFrame = document.createElement("iframe");
sameNamedFrame.name = targetKeyword;
document.body.appendChild(sameNamedFrame);

const form = document.createElement("form");
form.target = targetKeyword;
form.action =
  "resources/form-top-level-target-keywords-hop.html?target=" +
  encodeURIComponent(targetKeyword);
form.addEventListener("submit", function () {
  const count = Number(sessionStorage.getItem(key("submitCount:" + targetKeyword)) ?? "0") + 1;
  sessionStorage.setItem(key("submitCount:" + targetKeyword), String(count));
});

const hiddenTarget = document.createElement("input");
hiddenTarget.type = "hidden";
hiddenTarget.name = "target";
hiddenTarget.value = targetKeyword;
form.appendChild(hiddenTarget);

const submitter = document.createElement("button");
submitter.type = "submit";
submitter.textContent = "submit";
form.appendChild(submitter);

document.body.appendChild(form);
submitter.click();
</script>