|
7 | 7 | var sponsorCTA = sponsorSide && sponsorSide.querySelector(".sponsor-cta") |
8 | 8 | var sponsorSideBsa = document.querySelector(".sidesponsor-bsa") |
9 | 9 | var topSponsorBsa = document.querySelector(".topsponsor-bsa") |
| 10 | + var crawlerSlot = document.querySelector(".bsa-crawler-slot") |
| 11 | + var pageviewsSlot = document.querySelector(".bsa-pageviews-slot") |
10 | 12 |
|
11 | 13 | var bottomSponsor = document.querySelector(".bottomsponsor") |
12 | 14 | var bottomSponsorImg = bottomSponsor && bottomSponsor.querySelector("img") |
|
23 | 25 | !bottomSponsor || |
24 | 26 | !sponsorSideBsa || |
25 | 27 | !topSponsorBsa || |
| 28 | + !crawlerSlot || |
| 29 | + !pageviewsSlot || |
26 | 30 | !bottomSponsorBsa |
27 | 31 | ) { |
28 | 32 | return |
29 | 33 | } |
30 | 34 |
|
31 | 35 | var BSA_SCRIPT_BASE = "https://cdn4.buysellads.net/pub/hacktricks.js" |
| 36 | + var BSA_FIXED_LEADERBOARD_FALLBACK = { |
| 37 | + brokenId: "bsa-zone_1773065859037-5_123456", |
| 38 | + actualId: "bsa-zone_1770367111944-8_123456", |
| 39 | + } |
32 | 40 | var bsaScriptPromise |
33 | 41 |
|
34 | 42 | function getBsaScriptSrc() { |
|
49 | 57 | } |
50 | 58 |
|
51 | 59 | bsaScriptPromise = new Promise(function(resolve, reject) { |
| 60 | + var originalMapGet = Map.prototype.get |
| 61 | + var restoreMapGet = function() { |
| 62 | + Map.prototype.get = originalMapGet |
| 63 | + } |
| 64 | + |
| 65 | + Map.prototype.get = function(key) { |
| 66 | + if ( |
| 67 | + key === BSA_FIXED_LEADERBOARD_FALLBACK.brokenId && |
| 68 | + !this.has(key) && |
| 69 | + this.has(BSA_FIXED_LEADERBOARD_FALLBACK.actualId) |
| 70 | + ) { |
| 71 | + return originalMapGet.call(this, BSA_FIXED_LEADERBOARD_FALLBACK.actualId) |
| 72 | + } |
| 73 | + |
| 74 | + return originalMapGet.call(this, key) |
| 75 | + } |
| 76 | + |
52 | 77 | var bsaOptimize = document.createElement("script") |
53 | 78 | bsaOptimize.type = "text/javascript" |
54 | 79 | bsaOptimize.async = true |
55 | 80 | bsaOptimize.src = getBsaScriptSrc() |
56 | 81 | bsaOptimize.onload = function() { |
| 82 | + restoreMapGet() |
57 | 83 | resolve(bsaOptimize) |
58 | 84 | } |
59 | | - bsaOptimize.onerror = reject |
| 85 | + bsaOptimize.onerror = function(error) { |
| 86 | + restoreMapGet() |
| 87 | + reject(error) |
| 88 | + } |
60 | 89 | ;( |
61 | 90 | document.getElementsByTagName("head")[0] || |
62 | 91 | document.getElementsByTagName("body")[0] |
|
146 | 175 |
|
147 | 176 | async function loadBsaSponsor() { |
148 | 177 | bottomSponsorBsa.style.display = "block" |
| 178 | + |
149 | 179 | if (window.matchMedia("(min-width: 880px)").matches) { |
150 | 180 | sponsorSideBsa.style.display = "block" |
151 | 181 | topSponsorBsa.style.display = "none" |
152 | 182 | } else { |
153 | 183 | sponsorSideBsa.style.display = "none" |
154 | 184 | topSponsorBsa.style.display = "block" |
155 | 185 | } |
| 186 | + |
156 | 187 | await ensureBsaScript() |
157 | 188 | } |
158 | 189 |
|
|
0 commit comments