tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

branch.js (1806B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 "use strict";
      6 
      7 /**
      8 * Bug 1716220 - Shim Branch Web SDK
      9 *
     10 * Sites such as TataPlay may not load properly if Branch Web SDK is
     11 * blocked. This shim stubs out its script so the page still loads.
     12 */
     13 
     14 if (!window?.branch?.b) {
     15  const queue = window?.branch?._q || [];
     16  window.branch = new (class {
     17    V = {};
     18    g = 0;
     19    X = "web2.62.0";
     20    b = {
     21      A: {},
     22      clear() {},
     23      get() {},
     24      getAll() {},
     25      isEnabled: () => true,
     26      remove() {},
     27      set() {},
     28      ca() {},
     29      g: [],
     30      l: 0,
     31      o: 0,
     32      s: null,
     33    };
     34    addListener() {}
     35    applyCode() {}
     36    autoAppIndex() {}
     37    banner() {}
     38    c() {}
     39    closeBanner() {}
     40    closeJourney() {}
     41    constructor() {}
     42    creditHistory() {}
     43    credits() {}
     44    crossPlatformIds() {}
     45    data() {}
     46    deepview() {}
     47    deepviewCta() {}
     48    disableTracking() {}
     49    first() {}
     50    getBrowserFingerprintId() {}
     51    getCode() {}
     52    init(key, ...args) {
     53      const cb = args.pop();
     54      if (typeof cb === "function") {
     55        cb(undefined, {});
     56      }
     57    }
     58    lastAttributedTouchData() {}
     59    link() {}
     60    logEvent() {}
     61    logout() {}
     62    qrCode() {}
     63    redeem() {}
     64    referrals() {}
     65    removeListener() {}
     66    renderFinalize() {}
     67    renderQueue() {}
     68    sendSMS() {}
     69    setAPIResponseCallback() {}
     70    setBranchViewData() {}
     71    setIdentity() {}
     72    track() {}
     73    trackCommerceEvent() {}
     74    validateCode() {}
     75  })();
     76  const push = ([fn, ...args]) => {
     77    try {
     78      window.branch[fn].apply(window.branch, args);
     79    } catch (e) {
     80      console.error(e);
     81    }
     82  };
     83  queue.forEach(push);
     84 }