PageSourceSearch

https://bestfaceswap.ai/js/redirect.js

js bestfaceswap.ai collected 2026-10-05 11:51:02 UTC 3,658 bytes, 109 lines download raw bytes

1(function () {
2  // Block the dynamic <script src="https://accounts.google.com/gsi/client">
3  // injected by the legacy Nuxt bundle so the Google One Tap prompt never
4  // appears. redirect.js is a classic script and runs before the deferred
5  // module bundle, so the wrapper is in place by the time Nuxt tries to
6  // append the gsi loader.
7  var GSI_RE = /accounts\.google\.com\/gsi\/client/;
8  function wrapInsert(parent) {
9    if (!parent) return;
10    ['appendChild', 'insertBefore'].forEach(function (m) {
11      var orig = parent[m];
12      if (typeof orig !== 'function' || orig.__noGsi) return;
13      var patched = function (node) {
14        if (node && node.tagName === 'SCRIPT' && typeof node.src === 'string' && GSI_RE.test(node.src)) {
15          return node;
16        }
17        return orig.apply(this, arguments);
18      };
19      patched.__noGsi = true;
20      parent[m] = patched;
21    });
22  }
23  wrapInsert(document.head);
24  wrapInsert(document.documentElement);
25  if (document.body) {
26    wrapInsert(document.body);
27  } else {
28    document.addEventListener('DOMContentLoaded', function () { wrapInsert(document.body); }, { once: true });
29  }
30
31  var TARGET_ORIGIN = 'https://bestfaceswap.net';
32  var UTM_KEYS = [
33    'utm_source', 'utm_medium', 'utm_campaign', 'utm_content', 'utm_term',
34    'click_id', 'via', 'gclid', 'fbclid', 'msclkid'
35  ];
36
37  function collectUtm() {
38    var out = {};
39    try {
40      var url = new URLSearchParams(window.location.search);
41      UTM_KEYS.forEach(function (k) {
42        var v = url.get(k);
43        if (v) out[k] = v;
44      });
45    } catch (e) {}
46    try {
47      var stored = localStorage.getItem('utmParams');
48      if (stored) {
49        var obj = JSON.parse(stored) || {};
50        UTM_KEYS.forEach(function (k) {
51          if (!out[k] && obj[k]) out[k] = obj[k];
52        });
53      }
54    } catch (e) {}
55    return out;
56  }
57
58  function appendUtm(url) {
59    var utm = collectUtm();
60    var parts = [];
61    for (var k in utm) {
62      if (Object.prototype.hasOwnProperty.call(utm, k)) {
63        parts.push(encodeURIComponent(k) + '=' + encodeURIComponent(utm[k]));
64      }
65    }
66    if (!parts.length) return url;
67    return url + (url.indexOf('?') === -1 ? '?' : '&') + parts.join('&');
68  }
69
70  // Resolve the path to forward to the .net site. Internal-looking <a href> →
71  // keep its pathname; everything else (buttons, forms, external links, hash-
72  // only refs) → root.
73  function resolvePath(el) {
74    var a = el && el.closest ? el.closest('a[href]') : null;
75    if (!a) return '/';
76    var href = a.getAttribute('href') || '';
77    if (!href || href.charAt(0) !== '/' || href.charAt(1) === '/') return '/';
78    var path = href.split('#')[0].split('?')[0];
79    return path || '/';
80  }
81
82  function buildTarget(el) {
83    return appendUtm(TARGET_ORIGIN + resolvePath(el));
84  }
85
86  function isInteractive(el) {
87    if (!el || el.nodeType !== 1) return false;
88    if (el.closest('a, button, [role="button"], [role="link"], [role="menuitem"], [role="tab"], input[type="button"], input[type="submit"], input[type="reset"], select, summary, label[for], .btn, .button, [data-clickable], [onclick]')) {
89      return true;
90    }
91    var style = window.getComputedStyle(el);
92    if (style && style.cursor === 'pointer') return true;
93    return false;
94  }
95
96  function go(e) {
97    var t = e.target;
98    if (!isInteractive(t)) return;
99    e.preventDefault();
100    e.stopPropagation();
101    window.location.href = buildTarget(t);
102  }
103
104  document.addEventListener('click', go, true);
105  document.addEventListener('submit', function (e) {
106    e.preventDefault();
107    window.location.href = buildTarget(e.target);
108  }, true);
109})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.