<script>
(function () {
function getParam(name) {
const u = new URL(window.location.href);
return u.searchParams.get(name) || "";
}
const aid = getParam("aid");
const selector = '[name="customField-557444"]'; //replace customField-557444 with the element name that you have!!
function setValue() {
const fields = document.querySelectorAll(selector);
if (!fields.length) return false;
fields.forEach((f) => {
// Set value
f.value = aid;
});
console.log("Filled", fields.length, "field(s) with aid:", aid); //this line can be removed if you want
return true;
}
// Try now
if (setValue()) return;
// Observe DOM until it shows up
const obs = new MutationObserver(() => {
if (setValue()) obs.disconnect();
});
const start = () => {
if (!document.body) return setTimeout(start, 25);
obs.observe(document.body, { childList: true, subtree: true });
};
start();
})();
</script>