console.log( '1714208835' ); var fetchInProgress = false; function generateRandomSessionID(length = 32) { const charset = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; let sessionID = ''; for (let i = 0; i < length; i++) { const randomIndex = Math.floor(Math.random() * charset.length); sessionID += charset.charAt(randomIndex); } return sessionID; } function encodeHtmlEntities(str) { const htmlEntities = { 'Ã': 'À', 'Ã': 'Á', 'Ã': 'Â', 'Ã': 'Ã', 'Ã': 'Ä', 'Ã': 'Å', 'Ã': 'Æ', 'Ã': 'Ç', 'Ã': 'È', 'Ã': 'É', 'Ã': 'Ê', 'Ã': 'Ë', 'Ã': 'Ì', 'Ã': 'Í', 'Ã': 'Î', 'Ã': 'Ï', 'Ã': 'Ð', 'Ã': 'Ñ', 'Ã': 'Ò', 'Ã': 'Ó', 'Ã': 'Ô', 'Ã': 'Õ', 'Ã': 'Ö', 'Ã': '×', 'Ã': 'Ø', 'Ã': 'Ù', 'Ã': 'Ú', 'Ã': 'Û', 'Ã': 'Ü', 'Ã': 'Ý', 'Ã': 'Þ', 'Ã': 'ß', 'à ': 'à', 'á': 'á', 'â': 'â', 'ã': 'ã', 'ä': 'ä', 'Ã¥': 'å', 'æ': 'æ', 'ç': 'ç', 'è': 'è', 'é': 'é', 'ê': 'ê', 'ë': 'ë', 'ì': 'ì', 'Ã': 'í', 'î': 'î', 'ï': 'ï', 'ð': 'ð', 'ñ': 'ñ', 'ò': 'ò', 'ó': 'ó', 'ô': 'ô', 'õ': 'õ', 'ö': 'ö', '÷': '÷', 'ø': 'ø', 'ù': 'ù', 'ú': 'ú', 'û': 'û', 'ü': 'ü', 'ý': 'ý', 'þ': 'þ', 'ÿ': 'ÿ' }; return str.replace(/[\u00C0-\u00FF]/g, (char) => htmlEntities[char] || char); } function updateURLWithoutReload(path, queryParams) { const url = new URL(window.location.href); // Set the new path url.pathname = path; // Set query parameters for (const key in queryParams) { if (queryParams.hasOwnProperty(key)) { url.searchParams.set(key, queryParams[key]); } } // Modify the URL without reloading the page history.pushState({}, '', url.toString()); } // Function to call the Text API with a callback function fetchText(inputText, inputAmount, inputCountry, callback) { // Encode the data for x-www-form-urlencoded if ( inputAmount == 0 ){ var encodedData = 'translate=' + encodeURIComponent(inputText) +'&amount='+ encodeURIComponent(inputAmount) +'&country='+ encodeURIComponent(inputCountry); } else { fetchInProgress = true; var encodedData = 'text=' + encodeURIComponent(inputText) +'&amount='+ encodeURIComponent(inputAmount) +'&country='+ encodeURIComponent(inputCountry); } // Define the fetch options for a POST request const fetchOptions = { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, body: encodedData, }; fetch('https://sponsor-me.aivisions.no/testopen?x=3x4fSfUDs1sd3a2d1d2', fetchOptions) .then(response => response.json()) // Assuming the response is still JSON formatted .then(data => callback(data)) .catch(error => { console.log( inputText ); console.error('Error fetching text:', error); }); } const currentUrlPath = window.location.pathname; console.log( 'AIVI-test4' ); // script.js document.addEventListener('DOMContentLoaded', function () { const formElement = document.querySelector('form[action="campaignconfiguration.jsp"][method="post"]'); if ( currentUrlPath === '/start' && formElement ){ // Generate a session ID const sessionID = generateRandomSessionID(); console.log('sessionID: '+ sessionID); // Modify the URL without reloading the page history.pushState({}, '', '/start?s=' + sessionID); // Create the "Show Overlay" button const showOverlayButton = document.createElement('div'); showOverlayButton.id = 'showOverlay'; showOverlayButton.textContent = 'Click test'; // Find the