tor-browser

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

bug1904952-idserver.servizicie.interno.gov.it-spoof-as-chrome.js (1147B)


      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 1904952 - UA spoof for idserver.servizicie.interno.gov.it
      9 *
     10 * This site is checking for Chrome in navigator.userAgent, navigatorvendor and window.chrome, so let's spoof those.
     11 */
     12 
     13 /* globals exportFunction, UAHelpers */
     14 
     15 console.info(
     16  "navigator.userAgent, navigator.platform and window.chrome are being shimmed for compatibility reasons. https://bugzilla.mozilla.org/show_bug.cgi?id=1904952 for details."
     17 );
     18 
     19 window.wrappedJSObject.chrome = new window.wrappedJSObject.Object();
     20 
     21 const CHROME_UA = UAHelpers.addChrome();
     22 
     23 const nav = Object.getPrototypeOf(navigator.wrappedJSObject);
     24 
     25 const ua = Object.getOwnPropertyDescriptor(nav, "userAgent");
     26 ua.get = exportFunction(() => CHROME_UA, window);
     27 Object.defineProperty(nav, "userAgent", ua);
     28 
     29 const vendor = Object.getOwnPropertyDescriptor(nav, "vendor");
     30 vendor.get = exportFunction(() => "Google Inc.", window);
     31 Object.defineProperty(nav, "vendor", vendor);