/*! * consent-rto-eu — static loader (WEBSITES-7768, 2026-11-13). * * Static copy of the Data API record `consent-rto-eu`. The file lies exactly at the public URL * /api/data/get/consent-rto-eu (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 EU (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=2"; 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) { var savedData = getCookieSimple("yummyCookieWidget_userData_eu"); 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); })(); /** * URM Params */ document.addEventListener('DOMContentLoaded', () => { // getting utm_* from current url const pageParams = new URLSearchParams(window.location.search); const utmEntries = []; for (const [k, v] of pageParams) { if (k.toLowerCase().startsWith('utm_') && 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 для сопоставления const urlMappings = [ {"type":"B","id":1,"url":"https://www.dukascopy.com/land/trading/bank/forex/"}, {"type":"B","id":4,"url":"https://www.dukascopy.com/land/trading/eu/forex/"}, {"type":"B","id":7,"url":"https://www.dukascopy.com/land/trading/bank/platforms/"}, {"type":"B","id":10,"url":"https://www.dukascopy.com/land/trading/eu/platforms/"}, {"type":"B","id":869,"url":"https://www.dukascopy.com/land/trading/bank/crypto/"}, {"type":"B","id":881,"url":"https://www.dukascopy.com/land/trading/eu/crypto/"}, {"type":"B","id":1086,"url":"https://www.dukascopy.com/land/trading/bank/home/"}, {"type":"B","id":1414,"url":"https://www.dukascopy.com/land/trading/bank/home/"}, {"type":"L","id":190,"url":"https://www.dukascopy.com/land/open-live/eu/"}, {"type":"L","id":189,"url":"https://www.dukascopy.com/land/try-demo/eu/"}, {"type":"L","id":188,"url":"https://www.dukascopy.com/europe/english/platforms/mt5/ad-live/"}, {"type":"L","id":187,"url":"https://www.dukascopy.com/europe/english/platforms/mt4/ad-live/"}, {"type":"L","id":186,"url":"https://www.dukascopy.com/europe/english/platforms/jforex/"}, {"type":"L","id":185,"url":"https://www.dukascopy.com/land/try-demo/"}, {"type":"L","id":184,"url":"https://www.dukascopy.com/swiss/english/platforms/jforex/"}, {"type":"L","id":183,"url":"https://www.dukascopy.com/land/open-live/"}, {"type":"L","id":180,"url":"https://www.dukascopy.com/swiss/arabic/home/"}, {"type":"L","id":179,"url":"https://www.dukascopy.ch/swiss/chinese/home/"}, {"type":"L","id":178,"url":"https://www.dukascopy.com/swiss/pt/home/"}, {"type":"L","id":177,"url":"https://www.dukascopy.com/swiss/spanish/home/"}, {"type":"L","id":176,"url":"https://www.dukascopy.com/swiss/russian/home/"}, {"type":"L","id":175,"url":"https://www.dukascopy.com/swiss/deutsch/home/"}, {"type":"L","id":174,"url":"https://www.dukascopy.com/swiss/french/home/"}, {"type":"L","id":173,"url":"https://www.dukascopy.com/swiss/english/home/"}, {"type":"L","id":137,"url":"https://www.dukascopy.com/land/trading/eu/crypto/"}, {"type":"L","id":127,"url":"https://www.dukascopy.com/land/trading/bank/crypto/"}, {"type":"L","id":80,"url":"https://www.dukascopy.com/land/trading/bank/binaries/"}, {"type":"L","id":68,"url":"https://www.dukascopy.com/land/trading/eu/platforms/"}, {"type":"L","id":54,"url":"https://www.dukascopy.com/land/trading/bank/platforms/"}, {"type":"L","id":41,"url":"https://www.dukascopy.com/land/trading/eu/forex/"} ]; 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 */