tor-browser

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

bug1919263-nbcsports.com-getCurrentUser-script-error-fix.js (1056B)


      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 1919263 - nbcsports.com videos and photos are not displayed
      9 *
     10 * The site loads a script, mparticle.js, using a script tag with async=true,
     11 * but this can cause it to load too late for other scripts on the page. We
     12 * can prevent this by changing async to false when they try to load mparticle.js.
     13 */
     14 
     15 /* globals exportFunction */
     16 
     17 console.info(
     18  "mparticle.js is being kept from loading async. See https://bugzilla.mozilla.org/show_bug.cgi?id=1919263 for details."
     19 );
     20 
     21 const { prototype } = HTMLScriptElement.wrappedJSObject;
     22 const desc = Object.getOwnPropertyDescriptor(prototype, "src");
     23 const origSet = desc.set;
     24 desc.set = exportFunction(function (url) {
     25  if (url?.includes("mparticle.js")) {
     26    this.async = false;
     27  }
     28  return origSet.call(this, url);
     29 }, window);
     30 Object.defineProperty(prototype, "src", desc);