To jest placeholder.
Przejdź do trybu Podglądu lub opublikuj stronę,
aby sprawdzić działanie swojego kodu.
Kliknij dwa razy, aby edytować
<style>
[data-item-name="http_referer"] {
position: absolute !important;
left: -9999px !important;
width: 1px !important;
height: 1px !important;
overflow: hidden !important;
}
</style>
<script>
(function () {
// 1. Pobierz adres strony źródłowej
const params = new URLSearchParams(window.location.search);
const source = params.get("source_page") || document.referrer;
if (!source) return;
// 2. Akceptuj tylko adresy HANBUD
let url;
try {
url = new URL(source);
} catch (e) {
return;
}
const allowedDomains = [
"hanbud-dachy.pl",
"www.hanbud-dachy.pl"
];
if (!allowedDomains.includes(url.hostname.toLowerCase())) return;
if (!["https:", "http:"].includes(url.protocol)) return;
// Jeśli przeglądarka podała tylko domenę,
// nie udawaj, że znamy konkretną podstronę.
if (!params.has("source_page") && url.pathname === "/") return;
// 3. Przygotuj adres bez parametrów reklamowych
const sourceUrl = url.origin + url.pathname;
// 4. Wypełnij pole GetResponse
function fillField() {
const field = document.querySelector(
'input[name="http_referer"]'
);
if (!field) return false;
field.value = sourceUrl;
field.dispatchEvent(
new Event("input", { bubbles: true })
);
field.dispatchEvent(
new Event("change", { bubbles: true })
);
return true;
}
// 5. Obsłuż formularz ładowany z opóźnieniem
if (!fillField()) {
const observer = new MutationObserver(function () {
if (fillField()) observer.disconnect();
});
observer.observe(document.documentElement, {
childList: true,
subtree: true
});
setTimeout(function () {
observer.disconnect();
}, 10000);
}
})();
</script>