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