petar_bonov

ad referer fix

May 2nd, 2025 (edited)
232
0
243 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // BEFORE
  2.  
  3. const extractAdUnitId = (input) => {
  4.     const match = input.match(/_A\.(\d+)\./);
  5.     return match ? match[1] : "";
  6. };
  7. const divElement = document.createElement("div");
  8. const objectElement = document.createElement("object");
  9. objectElement.type = "text/html";
  10. const baseUrl = "https://img.gsmarena.com/banner.php3";
  11. const params = new URLSearchParams({
  12.     adUnitID: `${extractAdUnitId("/8095840/.2_A.35723.3_gsmarena.com_tier1")}`,
  13.     pageid: "1",
  14.     country: "RO",
  15.     lpe: "",
  16.     keyw: "",
  17.     visitqos: "1",
  18. });
  19. objectElement.data = `${baseUrl}?${params.toString()}`;
  20. objectElement.width = "728px";
  21. objectElement.height = "94px";
  22. objectElement.style.overflow = "auto";
  23. divElement.appendChild(objectElement);
  24. document.body.appendChild(divElement);
  25.  
  26. // AFTER
  27.  
  28. const extractAdUnitId = (input) => {
  29.     const match = input.match(/_A\.(\d+)\./);
  30.     return match ? match[1] : "";
  31. };
  32. const divElement = document.createElement("div");
  33. const baseUrl = "https://img.gsmarena.com/banner.php3";
  34. const params = new URLSearchParams({
  35.     adUnitID: `${extractAdUnitId("/8095840/.2_A.35723.3_gsmarena.com_tier1")}`,
  36.     pageid: "1",
  37.     country: "RO",
  38.     lpe: "",
  39.     keyw: "",
  40.     visitqos: "1",
  41. });
  42. const url = `${baseUrl}?${params.toString()}`;
  43. divElement.width = "728px";
  44. divElement.height = "94px";
  45. divElement.style.overflow = "auto";
  46. document.body.appendChild(divElement);
  47.  
  48. const xhr = new XMLHttpRequest();
  49. xhr.onreadystatechange = function() {
  50.     if (this.readyState == 4 && this.status == 200) {
  51.         const HTMLParser = new DOMParser();
  52.         const parsedDocument = HTMLParser.parseFromString(this.responseText, "text/html");
  53.         divElement.innerHTML = `${parsedDocument.head.innerHTML}${parsedDocument.body.innerHTML}`;
  54.     }
  55. };
  56. xhr.open("GET", url, true);
  57. xhr.send();
Advertisement
Add Comment
Please, Sign In to add comment