bug1819450-cmbchina.com-ua-change.js (905B)
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 1819450 - cmbchina.com - Override UA 9 * 10 * The site is using UA detection to redirect to 11 * m.cmbchina.com (mobile version of the site). Adding `SAMSUNG` allows 12 * to bypass the detection of mobile browser. 13 */ 14 15 /* globals exportFunction */ 16 17 console.info( 18 "The user agent has been overridden for compatibility reasons. See https://bugzilla.mozilla.org/show_bug.cgi?id=1081239 for details." 19 ); 20 21 const MODIFIED_UA = navigator.userAgent + " SAMSUNG"; 22 23 const nav = Object.getPrototypeOf(navigator.wrappedJSObject); 24 25 const ua = Object.getOwnPropertyDescriptor(nav, "userAgent"); 26 ua.get = exportFunction(() => MODIFIED_UA, window); 27 Object.defineProperty(nav, "userAgent", ua);