petar_bonov

ad referer fix - change

May 12th, 2025
179
0
253 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.  
  9. const baseUrl = "https://img.gsmarena.com/banner.php3";
  10. const params = new URLSearchParams({
  11.     adUnitID: `${extractAdUnitId("/8095840/.2_A.35723.3_gsmarena.com_tier1")}`,
  12.     pageid: "71",
  13.     country: "BG",
  14.     lpe: "low",
  15.     keyw: "Apple",
  16.     visitqos: "0",
  17. });
  18.  
  19. const url = `${baseUrl}?${params.toString()}`;
  20. divElement.style.width = "728px";
  21. divElement.style.height = "94px";
  22. divElement.style.overflow = "auto";
  23.  
  24. document.body.appendChild(divElement);
  25.  
  26.  
  27. const xhr = new XMLHttpRequest();
  28.  
  29. xhr.onreadystatechange = function() {
  30.  
  31.     if (this.readyState == 4 && this.status == 200) {
  32.         const HTMLParser = new DOMParser();
  33.         const parsedDocument = HTMLParser.parseFromString(this.responseText, "text/html");
  34.         divElement.innerHTML = `${parsedDocument.head.innerHTML}${parsedDocument.body.innerHTML}`; // <-- this line
  35.     }
  36.  
  37. };
  38. xhr.open("GET", url, true);
  39. xhr.send();
  40.  
  41. // AFTER
  42.  
  43. const extractAdUnitId = (input) => {
  44.     const match = input.match(/_A\.(\d+)\./);
  45.     return match ? match[1] : "";
  46. };
  47. const divElement = document.createElement("div");
  48.  
  49. const baseUrl = "https://img.gsmarena.com/banner.php3";
  50. const params = new URLSearchParams({
  51.     adUnitID: `${extractAdUnitId("/8095840/.2_A.35723.3_gsmarena.com_tier1")}`,
  52.     pageid: "71",
  53.     country: "BG",
  54.     lpe: "low",
  55.     keyw: "Apple",
  56.     visitqos: "0",
  57. });
  58.  
  59. const url = `${baseUrl}?${params.toString()}`;
  60. divElement.style.width = "728px";
  61. divElement.style.height = "94px";
  62. divElement.style.overflow = "auto";
  63.  
  64. document.body.appendChild(divElement);
  65.  
  66.  
  67. const xhr = new XMLHttpRequest();
  68.  
  69. xhr.onreadystatechange = function() {
  70.  
  71.     if (this.readyState == 4 && this.status == 200) {
  72.         const HTMLParser = new DOMParser();
  73.         const parsedDocument = HTMLParser.parseFromString(this.responseText, "text/html");
  74.         const fragment = document.createRange().createContextualFragment(`${parsedDocument.head.innerHTML}${parsedDocument.body.innerHTML}`);
  75.         divElement.appendChild(fragment);
  76.     }
  77.  
  78. };
  79. xhr.open("GET", url, true);
  80. xhr.send();
  81.  
Advertisement
Add Comment
Please, Sign In to add comment