/*! * consent-rto-swiss — static loader (WEBSITES-7768, 2026-11-13). * * Static copy of the Data API record `consent-rto-swiss`. The file lies exactly at the public URL * /api/data/get/consent-rto-swiss (no extension!), so the web server returns it from disk before * PHP and all existing consumers (RTO, jforex-land, ...) keep their src unchanged. It is loaded * synchronously in of RTO, so it must stay small and must not block on the network. * The response has no JS Content-Type (no extension); browsers execute it ONLY while the response * has no `X-Content-Type-Options: nosniff` — never enable nosniff for this path. * * Country: the old record received it from the server per request ({country} token). A static * file cannot, so the country is asked asynchronously from Cloudflare of the current host * (`/cdn-cgi/trace`, `loc=XX`, answered by the CF edge, ~0.1 s). Until the answer arrives the * consent stays "denied" (Consent Mode default). No answer → treated as EU (dialog shown). * Docs: dukascopy-com/docs/CONSENT-AND-COOKIES.md. */ (function () { "use strict"; console.log("-== PRE GTM Consent v1.6.0 (static) ==-"); if (typeof window.pageLang == "undefined") { window.pageLang = "en"; } if (typeof window.gtag !== "function") { window.dataLayer = window.dataLayer || []; window.gtag = function () { window.dataLayer.push(arguments); }; } window.gtag("consent", "default", { ad_storage: "denied", ad_user_data: "denied", ad_personalization: "denied", analytics_storage: "denied", wait_for_update: 2000, }); var euCountries = ["AT", "BE", "BG", "HR", "CY", "CZ", "DK", "EE", "FI", "FR", "DE", "GR", "HU", "IS", "IE", "IT", "LV", "LI", "LT", "LU", "MT", "NL", "NO", "PL", "PT", "RO", "SK", "SI", "ES", "SE", "GB"]; var COUNTRY_KEY = "cwUserCountry"; var TRACE_TIMEOUT = 1500; function getCookieSimple(name) { var searchName = name + "="; var cookiesArray = decodeURIComponent(document.cookie).split("; "); var find = cookiesArray.find(function (item) { return item.indexOf(searchName) === 0; }); return find ? find.substring(searchName.length) : ""; } function saveGtagDataSimple(data) { try { window.gtag("consent", "update", { ad_storage: data.advertising ? "granted" : "denied", analytics_storage: data.performance ? "granted" : "denied", ad_personalization: data.personalizedAdvertising ? "granted" : "denied", ad_user_data: data.useDataForAdvertising ? "granted" : "denied", }); console.log("-== Consent was updated from cookie ==-"); } catch (e) { console.log("Google tag manager is not found"); } } function whenDomReady(fn) { if (document.readyState === "loading") { document.addEventListener("DOMContentLoaded", fn); } else { fn(); } } function addCookieScript() { var openPrivacySettingsElement = document.getElementById("open-privacy-settings"); if (openPrivacySettingsElement) { openPrivacySettingsElement.addEventListener("click", function (e) { e.preventDefault(); if (window.yummyCookieWidget) { window.yummyCookieWidget.setWidgetVisibility(true); window.yummyCookieWidget.setScreenVisibility(1); } }); } if (document.getElementById("ycw-script")) { return; } var scriptElement = document.createElement("script"); scriptElement.id = "ycw-script"; scriptElement.async = true; scriptElement.src = "https://www.dukascopy.com/api/data/get/yummyCookieWidget?lang=" + window.pageLang + "&forJs=1&branchId=1&noCache=0&v=2.1.0"; document.body.appendChild(scriptElement); if (document.cookie.indexOf("yummyCookieWidget") === -1) { try { window.dataLayer.push({ event: "cookie_bnr_show_dur" }); } catch (e) {} } } function applyCountry(country) { window.cwUserCountry = country; // Unknown country (no answer from Cloudflare) is treated as EU: dialog instead of silent consent. var isEu = !country || euCountries.indexOf(country) > -1; if (isEu && document.location.host !== "www.jforex.net") { var savedData = getCookieSimple("yummyCookieWidget_userData"); if (savedData) { try { console.log("--== Restore consent from cookie ==---"); saveGtagDataSimple(JSON.parse(savedData)); } catch (e) { console.log("--== Invalid consent cookie, skip restore ==--"); } } whenDomReady(addCookieScript); return; } // For non-EU countries, we assume consent is granted by default window.gtag("consent", "update", { ad_storage: "granted", ad_user_data: "granted", ad_personalization: "granted", analytics_storage: "granted", }); whenDomReady(function () { var el = document.getElementById("open-privacy-settings"); if (el && el.parentElement) { el.parentElement.style.display = "none"; } }); } function resolveCountry(done) { var forced = /[?&]force_country=([A-Za-z]{2})/.exec(document.location.search); if (forced) { return done(forced[1].toUpperCase()); } try { var cached = sessionStorage.getItem(COUNTRY_KEY); if (cached) { return done(cached); } } catch (e) {} var finished = false; function finish(country) { if (finished) return; finished = true; if (country) { try { sessionStorage.setItem(COUNTRY_KEY, country); } catch (e) {} } done(country); } setTimeout(function () { finish(null); }, TRACE_TIMEOUT); try { var xhr = new XMLHttpRequest(); xhr.open("GET", "/cdn-cgi/trace", true); xhr.timeout = TRACE_TIMEOUT; xhr.onload = function () { var m = /^loc=([A-Z]{2})$/m.exec(xhr.responseText || ""); finish(m && m[1] !== "XX" && m[1] !== "T1" ? m[1] : null); }; xhr.onerror = xhr.ontimeout = function () { finish(null); }; xhr.send(); } catch (e) { finish(null); } } resolveCountry(applyCountry); })(); /** * UTM Params */ document.addEventListener("DOMContentLoaded", () => { // Getting utm_* + clickid + ibref from current url // Собираем utm_*, clickid и ibref из текущего URL const pageParams = new URLSearchParams(window.location.search); const EXTRA_PARAMS = ["clickid", "ibref"]; const utmEntries = []; for (const [k, v] of pageParams) { if ((k.toLowerCase().startsWith("utm_") || EXTRA_PARAMS.includes(k)) && v !== "") { utmEntries.push([k, v]); } } const hasUtm = utmEntries.length > 0; // 2) Lats find all links (exclude mailto:/tel:/javascript:) const anchors = Array.from( document.querySelectorAll('a[href*=".dukascopy.com/rto3"]') ).filter((a) => { const href = a.getAttribute("href") || ""; return !/^(mailto:|tel:|javascript:)/i.test(href); }); // 3) Update links const base = document.baseURI || window.location.href; let modified = 0; anchors.forEach((a) => { // Disassamble links const url = new URL(a.getAttribute("href"), base); if (hasUtm) { const sp = url.searchParams; for (const [k, v] of utmEntries) sp.set(k, v); url.search = sp.toString(); // save other parameters a.setAttribute("href", url.toString()); // save hash/fragment modified++; } }); // some debug info console.log({ hasUtm, utmKeys: utmEntries.map(([k]) => k), targetsFound: anchors.length, targetsModified: modified, }); }); /** * IB REVERSE BLOCK */ (function () { "use strict"; // URL mappings: compact format "type|id|url" // Маппинг URL: компактный формат "тип|id|url" const urlMappings = [ "B|1|https://www.dukascopy.com/land/trading/bank/forex/", "B|4|https://www.dukascopy.com/land/trading/eu/forex/", "B|7|https://www.dukascopy.com/land/trading/bank/platforms/", "B|10|https://www.dukascopy.com/land/trading/eu/platforms/", "B|869|https://www.dukascopy.com/land/trading/bank/crypto/", "B|881|https://www.dukascopy.com/land/trading/eu/crypto/", "B|1086|https://www.dukascopy.com/land/trading/bank/home/", "B|1414|https://www.dukascopy.com/land/trading/bank/home/", "L|190|https://www.dukascopy.com/land/open-live/eu/", "L|189|https://www.dukascopy.com/land/try-demo/eu/", "L|188|https://www.dukascopy.com/europe/english/platforms/mt5/ad-live/", "L|187|https://www.dukascopy.com/europe/english/platforms/mt4/ad-live/", "L|186|https://www.dukascopy.com/europe/english/platforms/jforex/", "L|185|https://www.dukascopy.com/land/try-demo/", "L|184|https://www.dukascopy.com/swiss/english/platforms/jforex/", "L|183|https://www.dukascopy.com/land/open-live/", "L|180|https://www.dukascopy.com/swiss/arabic/home/", "L|179|https://www.dukascopy.ch/swiss/chinese/home/", "L|178|https://www.dukascopy.com/swiss/pt/home/", "L|177|https://www.dukascopy.com/swiss/spanish/home/", "L|176|https://www.dukascopy.com/swiss/russian/home/", "L|175|https://www.dukascopy.com/swiss/deutsch/home/", "L|174|https://www.dukascopy.com/swiss/french/home/", "L|173|https://www.dukascopy.com/swiss/english/home/", "L|137|https://www.dukascopy.com/land/trading/eu/crypto/", "L|127|https://www.dukascopy.com/land/trading/bank/crypto/", "L|80|https://www.dukascopy.com/land/trading/bank/binaries/", "L|68|https://www.dukascopy.com/land/trading/eu/platforms/", "L|54|https://www.dukascopy.com/land/trading/bank/platforms/", "L|41|https://www.dukascopy.com/land/trading/eu/forex/", // Parse compact strings into objects: [type, id, url] // Разбираем строки в объекты: [тип, id, url] ].map((s) => { const [type, id, url] = s.split("|"); return { type, id: +id, url }; }); function getURLParams() { const params = {}; const searchParams = new URLSearchParams(window.location.search); for (const [key, value] of searchParams) { params[key] = value; } return params; } function isInteger(value) { return /^\d+$/.test(value); } function normalizeURL(url) { try { const urlObj = new URL(url); let normalizedHost = urlObj.hostname.replace(/^www\./, ""); let normalizedPath = urlObj.pathname; let normalizedSearch = urlObj.search; return normalizedHost + normalizedPath + normalizedSearch; } catch (e) { return null; } } /** * Найти соответствующий элемент в массиве по URL */ function findMatchingElement(currentURL) { const normalizedCurrentURL = normalizeURL(currentURL); if (!normalizedCurrentURL) return null; for (const element of urlMappings) { const normalizedElementURL = normalizeURL(element.url); if ( normalizedElementURL && normalizedCurrentURL.indexOf(normalizeURL(element.url)) === 0 ) { console.log("Matched URL:", normalizedElementURL); return element; } } return null; } /** * Создать URL редиректа */ function createRedirectURL(ibref, type, linkId, currentParams) { const filteredParams = { ...currentParams }; delete filteredParams.ibref; // Базовый шаблон редиректа - замените на ваш реальный шаблон let redirectURL = `https://www.dukascopy.com/api/ib/${ibref}/type-${type}/target-id-${linkId}`; if (Object.keys(filteredParams).length > 0) { // Проверяем есть ли уже параметры в URL const separator = redirectURL.includes("?") ? "&" : "?"; const additionalParams = Object.keys(filteredParams) .map((key) => `${key}=${encodeURIComponent(filteredParams[key])}`) .join("&"); redirectURL += separator + additionalParams; } return redirectURL; } /** * Основная функция проверки и редиректа */ function checkAndRedirect() { console.log("Running redirect script..."); try { const params = getURLParams(); const ibref = params.ibref; const clickid = params.clickid; if (!ibref || clickid !== undefined) { return; } if (!isInteger(ibref)) { return; } const currentURL = window.location.href; const matchingElement = findMatchingElement(currentURL); if (matchingElement) { // Создаем URL редиректа const redirectURL = createRedirectURL( ibref, matchingElement.type, matchingElement.id, params ); // Выполняем редирект console.log("Redirecting to:", redirectURL); // alert(redirectURL); window.location.href = redirectURL; } else { console.log("No matching URL found for redirection."); } } catch (error) { console.error("Error in redirect script:", error); } } // Запускаем проверку после загрузки DOM //if (document.readyState === 'loading') { // document.addEventListener('DOMContentLoaded', checkAndRedirect); //} else { checkAndRedirect(); //} })(); /** * End IB REVERSE BLOCK */