// BEFORE const extractAdUnitId = (input) => { const match = input.match(/_A\.(\d+)\./); return match ? match[1] : ""; }; const divElement = document.createElement("div"); const objectElement = document.createElement("object"); objectElement.type = "text/html"; const baseUrl = "https://img.gsmarena.com/banner.php3"; const params = new URLSearchParams({ adUnitID: `${extractAdUnitId("/8095840/.2_A.35723.3_gsmarena.com_tier1")}`, pageid: "1", country: "RO", lpe: "", keyw: "", visitqos: "1", }); objectElement.data = `${baseUrl}?${params.toString()}`; objectElement.width = "728px"; objectElement.height = "94px"; objectElement.style.overflow = "auto"; divElement.appendChild(objectElement); document.body.appendChild(divElement); // AFTER const extractAdUnitId = (input) => { const match = input.match(/_A\.(\d+)\./); return match ? match[1] : ""; }; const divElement = document.createElement("div"); const baseUrl = "https://img.gsmarena.com/banner.php3"; const params = new URLSearchParams({ adUnitID: `${extractAdUnitId("/8095840/.2_A.35723.3_gsmarena.com_tier1")}`, pageid: "1", country: "RO", lpe: "", keyw: "", visitqos: "1", }); const url = `${baseUrl}?${params.toString()}`; divElement.width = "728px"; divElement.height = "94px"; divElement.style.overflow = "auto"; document.body.appendChild(divElement); const xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { const HTMLParser = new DOMParser(); const parsedDocument = HTMLParser.parseFromString(this.responseText, "text/html"); divElement.innerHTML = `${parsedDocument.head.innerHTML}${parsedDocument.body.innerHTML}`; } }; xhr.open("GET", url, true); xhr.send();