tor-browser

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

bug1898946-transcrib.io-chrome-shim.js (1072B)


      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 1898946 - UA spoof for transcrib.io
      9 *
     10 * This checks navigator.userAgent and navigator.vendor to detect Chrome,
     11 * so let's set appropriate values to also look like Chrome.
     12 */
     13 
     14 /* globals exportFunction */
     15 
     16 console.info(
     17  "The user agent and navigator.vendor have been shimmed for compatibility reasons. See https://bugzilla.mozilla.org/show_bug.cgi?id=1898946 for details."
     18 );
     19 
     20 const CHROME_UA = navigator.userAgent + " Chrome for WebCompat";
     21 
     22 Object.defineProperty(window.navigator.wrappedJSObject, "userAgent", {
     23  get: exportFunction(function () {
     24    return CHROME_UA;
     25  }, window),
     26 
     27  set: exportFunction(function () {}, window),
     28 });
     29 
     30 Object.defineProperty(window.navigator.wrappedJSObject, "vendor", {
     31  get: exportFunction(function () {
     32    return "Google Inc.";
     33  }, window),
     34 
     35  set: exportFunction(function () {}, window),
     36 });