-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathpostPilotLink.js
More file actions
436 lines (377 loc) · 15.9 KB
/
Copy pathpostPilotLink.js
File metadata and controls
436 lines (377 loc) · 15.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
// linking — fixed version
(function() {
var adList = [
"https://spreadpreferencetelevision.com/tba2ybi8y?key=e9181f1e0055b64f2438c9cf18ca8880",
"https://spreadpreferencetelevision.com/x2fusvgn?key=2531ef9b0b688c0f6205ee45da3c50de"
// FIX 1: removed duplicate entry (was repeated as index 2)
];
var SECRET_KEY = "XP_DekhoPrimeBlog2027";
var WAIT_TIME = 15;
var MARKER_SELECTOR = '#unlock-link, .unlock-link, [data-unlock-link], [id*="unlock-link"]:not([id^="unlock-link-host-"])';
var scanScheduled = false;
var initialized = false;
var statusTexts = [
"Syncing Node...",
"Verifying View...",
"Encrypting Connection...",
"BDIX Routing Check...",
"Finalizing Protocol..."
];
function xorDecrypt(hex, key) {
var result = "";
for (var i = 0; i < hex.length; i += 2) {
var code = parseInt(hex.substr(i, 2), 16) ^ key.charCodeAt((i / 2) % key.length);
result += String.fromCharCode(code);
}
return result;
}
// Open the ad link in a real browser tab.
function openInBrowser(url) {
var opened = null;
// 1) Preferred: real browser tab via window.open with explicit features.
// Passing a non-empty features string keeps Chrome from treating this
// as a popup window and lets it land in a normal tab.
try {
opened = window.open(url, '_blank', 'noopener,noreferrer,width=1,height=1');
} catch (e1) {
opened = null;
}
// 2) Anchor fallback. This is the path that almost always works, and
// it lets Adsterra's redirect chain run inside a real tab.
var a = document.createElement('a');
a.href = url;
a.target = '_blank';
a.rel = 'noopener noreferrer nofollow';
a.style.cssText = 'display:none;';
document.body.appendChild(a);
a.click();
// If window.open already produced a real handle, the anchor click above
// would open a *second* tab. To avoid that, we delay removal just long
// enough for the click to be processed, but only when the popup call
// succeeded — otherwise the anchor click is the only thing the user
// has, so we keep the element around for the manual-fallback path.
if (opened) {
setTimeout(function() {
if (a && a.parentNode) a.parentNode.removeChild(a);
}, 0);
try { opened.focus(); } catch (e2) {}
}
// 3) Manual fallback (sandboxed contexts, popup blockers that also
// suppress synthetic anchor clicks). Surface a visible "Open ad"
// button the user can click themselves.
if (!opened) {
try {
a.textContent = 'Click here to open the ad';
a.style.cssText =
'display:inline-block;background:#0984e3;color:#fff;' +
'padding:8px 14px;border-radius:6px;text-decoration:none;' +
'font-weight:700;font-size:13px;margin-top:8px;';
} catch (e3) {}
}
return opened;
}
function normalizeUrl(value) {
var raw = (value || '').trim();
if (!raw) return '';
if (/^https?:\/\//i.test(raw)) return raw;
if (/^\/\//.test(raw)) return 'https:' + raw;
if (/^[a-z0-9.-]+\.[a-z]{2,}(?::\d+)?(?:\/|$)/i.test(raw)) {
return 'https://' + raw;
}
return '';
}
function extractUrlLike(value) {
var raw = (value || '').trim();
if (!raw) return '';
var m = raw.match(/https?:\/\/[^\s"'<>]+|\/\/[^\s"'<>]+|[a-z0-9.-]+\.[a-z]{2,}(?::\d+)?\/[^\s"'<>]+/i);
return m ? m[0] : '';
}
function extractHexPayload(value) {
var raw = (value || '').trim();
if (!raw) return '';
var compact = raw.replace(/\s+/g, '');
if (/^[0-9a-f]+$/i.test(compact) && compact.length >= 16 && compact.length % 2 === 0) {
return compact;
}
var m = compact.match(/[0-9a-f]{16,}/ig);
if (!m) return '';
for (var i = 0; i < m.length; i++) {
if (m[i].length % 2 === 0) return m[i];
}
return '';
}
function injectStyles() {
if (document.getElementById('locker-styles')) return;
var style = document.createElement('style');
style.id = 'locker-styles';
style.textContent = [
'.locker-box{background:#fff;border-radius:10px;padding:20px;text-align:center;margin:15px auto;max-width:400px;width:100%;box-shadow:0 5px 20px rgba(0,0,0,0.08);border:1px solid #f0f3f5;font-family:sans-serif;box-sizing:border-box;}',
'.locker-box h3{margin:0 0 8px;color:#2d3436;font-size:18px;font-weight:700;}',
'.locker-box p{margin:0 0 20px;color:#636e72;font-size:13px;line-height:1.4;}',
'.locker-progress-wrap{width:100%;height:8px;background:#f1f2f6;border-radius:10px;overflow:hidden;margin-bottom:15px;}',
'.locker-progress-bar{width:0%;height:100%;background:#0984e3;transition:width 0.3s ease;}',
'.locker-status-row{display:flex;justify-content:space-between;margin-bottom:8px;font-size:12px;font-weight:bold;color:#2d3436;}',
'.locker-btn{background:#0984e3;color:#fff;border:none;padding:12px 25px;border-radius:6px;font-weight:700;cursor:pointer;width:100%;font-size:14px;text-transform:uppercase;font-family:sans-serif;transition:0.2s;}',
'.locker-btn:disabled{background:#b2bec3;cursor:not-allowed;}',
'.locker-btn-success{background:#00b894;}',
'.locker-warning{display:none;background:#fff9db;color:#e67e22;padding:8px;border-radius:6px;font-size:11px;font-weight:bold;border:1px solid #ffe066;margin-top:10px;}',
'.locker-inline-msg{display:none;background:#fff4f4;color:#d63031;padding:8px;border-radius:6px;font-size:11px;font-weight:700;border:1px solid #ffcccc;margin-top:10px;}',
'.locker-placeholder{color:#636e72;font-size:13px;}',
].join('');
document.head.appendChild(style);
}
function renderLocker(target, destinationURL) {
target.style.display = 'block';
target.innerHTML =
'<div class="locker-box">' +
'<div class="lk-start">' +
'<div style="font-size:32px;margin-bottom:8px;">🔒</div>' +
'<h3>Link Encrypted</h3>' +
'<p>Unlock with 15-second ad verification.</p>' +
'<button class="locker-btn lk-btn-start">UNLOCK NOW</button>' +
'<div class="locker-inline-msg lk-inline-msg"></div>' +
'</div>' +
'<div class="lk-process" style="display:none;">' +
'<div class="locker-status-row">' +
'<span class="lk-status">Initializing...</span>' +
'<span class="lk-percent">0%</span>' +
'</div>' +
'<div class="locker-progress-wrap">' +
'<div class="locker-progress-bar"></div>' +
'</div>' +
'<div class="locker-warning lk-warning"></div>' +
'</div>' +
'<div class="lk-final" style="display:none;">' +
'<div style="font-size:32px;margin-bottom:8px;">✅</div>' +
'<h3 style="color:#00b894;">Verification Success</h3>' +
'<button class="locker-btn locker-btn-success lk-btn-copy">COPY LINK</button>' +
'</div>' +
'</div>';
var stepStart = target.querySelector('.lk-start');
var stepProcess = target.querySelector('.lk-process');
var stepFinal = target.querySelector('.lk-final');
var progressBar = target.querySelector('.locker-progress-bar');
var percentText = target.querySelector('.lk-percent');
var statusMsg = target.querySelector('.lk-status');
var warningBox = target.querySelector('.lk-warning');
var inlineMsg = target.querySelector('.lk-inline-msg');
var btnStart = target.querySelector('.lk-btn-start');
var btnCopy = target.querySelector('.lk-btn-copy');
var adWindow = null;
var timeLeft = WAIT_TIME;
var timerInterval = null;
var started = false;
// FIX 4: cleanup interval on page unload to prevent memory leaks
window.addEventListener('beforeunload', function() {
if (timerInterval) clearInterval(timerInterval);
});
btnStart.addEventListener('click', function() {
if (started) return;
started = true;
if (inlineMsg) {
inlineMsg.style.display = 'none';
inlineMsg.textContent = '';
}
var randomLink = adList[Math.floor(Math.random() * adList.length)];
adWindow = openInBrowser(randomLink);
// Note: when the anchor-click fallback opened the tab, `adWindow`
// is null but the ad tab *is* still opening. We only treat this as
// a hard failure if neither path produced evidence of a tab. The
// document.hidden check below is what actually drives progress.
if (!adWindow) {
// No popup handle — the anchor fallback path is our only hope.
// If the user is sandboxed or popups are fully blocked, the
// document.hidden check will never fire and the timer stays paused
// with the "Stay on Ad Page" warning. We add a softer hint here.
if (inlineMsg) {
inlineMsg.style.display = 'block';
inlineMsg.textContent = 'If the ad tab did not open, allow popups and try again.';
}
}
stepStart.style.display = 'none';
stepProcess.style.display = 'block';
timerInterval = setInterval(function() {
// FIX 3: reset started flag so user can retry after abort.
// Only meaningful when window.open returned a real handle.
// When the anchor-fallback opened the tab, adWindow is null and
// we rely on document.hidden to detect "user left this tab".
if (adWindow && adWindow.closed) {
warningBox.style.display = 'block';
warningBox.textContent = '⚠️ Ad Closed! Please reload and try again.';
statusMsg.textContent = 'Process Aborted';
started = false;
clearInterval(timerInterval);
return;
}
// FIX 2: was (!document.hidden) — completely inverted.
// document.hidden === true → user is on the ad tab (away from this page) → count down.
// document.hidden === false → user is back on this page → pause and warn.
if (!document.hidden) {
warningBox.style.display = 'block';
warningBox.textContent = '⚠️ Stay on Ad Page to Continue!';
statusMsg.textContent = 'Timer Paused';
return;
}
// User is on ad tab — count down
warningBox.style.display = 'none';
timeLeft--;
var percent = Math.floor(((WAIT_TIME - timeLeft) / WAIT_TIME) * 100);
progressBar.style.width = percent + '%';
percentText.textContent = percent + '%';
if (timeLeft % 4 === 0) {
statusMsg.textContent = statusTexts[Math.floor(Math.random() * statusTexts.length)];
}
if (timeLeft <= 0) {
clearInterval(timerInterval);
stepProcess.style.display = 'none';
stepFinal.style.display = 'block';
}
}, 1000);
});
btnCopy.addEventListener('click', function() {
if (navigator.clipboard) {
navigator.clipboard.writeText(destinationURL).then(function() {
btnCopy.textContent = 'COPIED! ✅';
setTimeout(function() { window.location.href = destinationURL; }, 1000);
});
} else {
var tmp = document.createElement('input');
tmp.value = destinationURL;
tmp.style.cssText = 'position:fixed;opacity:0;';
document.body.appendChild(tmp);
tmp.select();
document.execCommand('copy');
document.body.removeChild(tmp);
btnCopy.textContent = 'COPIED! ✅';
setTimeout(function() { window.location.href = destinationURL; }, 1000);
}
});
}
function getOrCreateRenderHost(node) {
if (node.classList && node.classList.contains('unlock-link-host')) return node;
var existingHostId = node.getAttribute('data-locker-host-id');
if (existingHostId) {
var existingHost = document.getElementById(existingHostId);
if (existingHost) return existingHost;
}
var host = document.createElement('div');
var hostId = 'unlock-link-host-' + Math.random().toString(36).slice(2, 10);
host.id = hostId;
host.className = 'unlock-link-host';
if (node.parentNode) {
node.parentNode.insertBefore(host, node.nextSibling);
}
node.setAttribute('data-locker-host-id', hostId);
return host;
}
function isLockerHostNode(node) {
return !!(node && node.nodeType === 1 && node.classList && node.classList.contains('unlock-link-host'));
}
function toElement(node) {
if (!node) return null;
if (node.nodeType === 1) return node;
if (node.nodeType === 3) return node.parentElement;
return null;
}
function isMarkerNode(node) {
var el = toElement(node);
if (!el || isLockerHostNode(el)) return false;
try { return el.matches(MARKER_SELECTOR); } catch(e) { return false; }
}
function containsMarkerNode(node) {
var el = toElement(node);
if (!el || isLockerHostNode(el)) return false;
if (isMarkerNode(el)) return true;
if (!el.querySelector) return false;
return !!el.querySelector(MARKER_SELECTOR);
}
function scheduleScan() {
if (scanScheduled) return;
scanScheduled = true;
setTimeout(function() {
scanScheduled = false;
scanAndInit();
}, 50);
}
function scanAndInit() {
var list = Array.prototype.slice.call(document.querySelectorAll(MARKER_SELECTOR));
list.forEach(function(node) {
if (isLockerHostNode(node)) return;
var host = getOrCreateRenderHost(node);
if (host !== node) node.style.display = 'none';
if (host.getAttribute('data-locker-init') === 'true') return;
var encrypted = (
node.getAttribute('data-encrypted') ||
node.getAttribute('data-token') ||
node.getAttribute('data-url') ||
node.textContent ||
''
).trim();
if (!encrypted) {
if (!host.querySelector('.locker-box')) {
host.style.display = 'block';
host.innerHTML = '<div class="locker-box"><div class="locker-placeholder">Preparing secure link...</div></div>';
}
return;
}
var decrypted = '';
try {
var directUrl = normalizeUrl(encrypted) || normalizeUrl(extractUrlLike(encrypted));
if (directUrl) {
decrypted = directUrl;
} else {
var hexPayload = extractHexPayload(encrypted);
if (hexPayload) {
decrypted = normalizeUrl(xorDecrypt(hexPayload, SECRET_KEY));
}
}
} catch(e) { decrypted = ''; }
if (!decrypted) {
host.style.display = 'block';
host.innerHTML = '<div class="locker-box"><h3>Link Unavailable</h3><p>Unlock payload is missing or invalid. Please refresh the page.</p></div>';
host.removeAttribute('data-locker-init');
return;
}
try {
renderLocker(host, decrypted);
host.setAttribute('data-locker-init', 'true');
} catch(e) {
host.style.display = 'block';
host.innerHTML = '<div class="locker-box"><h3>Link Unavailable</h3><p>Failed to render unlock layout. Please refresh the page.</p></div>';
host.setAttribute('data-locker-init', 'true');
}
});
}
function init() {
if (initialized) return;
initialized = true;
injectStyles();
scanAndInit();
new MutationObserver(function(mutations) {
for (var i = 0; i < mutations.length; i++) {
var mutation = mutations[i];
var targetEl = toElement(mutation.target);
if (targetEl && targetEl.closest && targetEl.closest('.unlock-link-host')) continue;
if (mutation.type === 'characterData') {
if (isMarkerNode(targetEl)) { scheduleScan(); return; }
continue;
}
if (mutation.type === 'childList') {
if (containsMarkerNode(targetEl)) { scheduleScan(); return; }
for (var j = 0; j < mutation.addedNodes.length; j++) {
if (containsMarkerNode(mutation.addedNodes[j])) { scheduleScan(); return; }
}
}
}
}).observe(document.body, {
childList: true,
subtree: true,
characterData: true
});
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', init);
} else {
init();
}
})();