tor-browser

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

bug1799968-www.samsung.com-appVersion-linux-fix.js (1122B)


      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 1799968 - Build site patch for www.samsung.com on Linux
      9 * Bug 1860417 - and Android
     10 * WebCompat issue #108993 - https://webcompat.com/issues/108993
     11 *
     12 * Samsung's Watch pages try to detect the OS via navigator.appVersion,
     13 * but fail with Linux and Android because they expect it to contain the
     14 * literal string "linux", and their JS breaks.
     15 *
     16 * As such this site patch sets appVersion to "5.0 (Linux)", and is
     17 * only meant to be applied on Linux or Android.
     18 */
     19 
     20 /* globals exportFunction */
     21 
     22 console.info(
     23  "navigator.appVersion has been shimmed for compatibility reasons. See https://webcompat.com/issues/108993 for details."
     24 );
     25 
     26 const nav = Object.getPrototypeOf(navigator.wrappedJSObject);
     27 const appVersion = Object.getOwnPropertyDescriptor(nav, "appVersion");
     28 appVersion.get = exportFunction(() => "5.0 (Linux)", window);
     29 Object.defineProperty(nav, "appVersion", appVersion);