tor-browser

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

bug1930440-online.singaporepools.com-prevent-unsupported-alert.js (1365B)


      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 /* globals exportFunction */
      6 
      7 "use strict";
      8 
      9 /**
     10 * online.singaporepools.com - Shows an 'unsupported browser' alert
     11 * Bug #1930440 - https://bugzilla.mozilla.org/show_bug.cgi?id=1930440
     12 * WebCompat issue #143685 - https://webcompat.com/issues/143685
     13 *
     14 * We can intercept the call to alert and hide it, as well as hide the
     15 * additional in-page support message that they show to all browsers.
     16 */
     17 
     18 console.info(
     19  "window.alert is being overriden for compatibility reasons. See https://bugzilla.mozilla.org/show_bug.cgi?id=1923286 for details."
     20 );
     21 
     22 new MutationObserver(mutations => {
     23  for (let { addedNodes } of mutations) {
     24    for (const node of addedNodes) {
     25      try {
     26        if (
     27          node.matches(".alert.views-row") &&
     28          node.innerText.includes("Chrome")
     29        ) {
     30          node.remove();
     31        }
     32      } catch (_) {}
     33    }
     34  }
     35 }).observe(document.documentElement, {
     36  childList: true,
     37  subtree: true,
     38 });
     39 
     40 const originalAlert = window.wrappedJSObject.alert;
     41 window.wrappedJSObject.alert = exportFunction(function (msg) {
     42  if (!msg?.toLowerCase?.().includes("unsupported browser")) {
     43    originalAlert(msg);
     44  }
     45 }, window);