tor-browser

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

aliexpress-language.js (1478B)


      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 1912228  - aliexpress.com - Unable to change the shipping location back to default
      9 *
     10 * Changing the shipping location relies upon access to the unpartitioned cookies for login.aliexpress.com,
     11 * which are unavailable for localized domains like aliexpress.us. This calls the priveleged Storage Access API
     12 * for those domains when the user engages with the internationalization UX.
     13 */
     14 
     15 console.warn(
     16  `When changing languages, Firefox calls the Storage Access API on behalf of the site. See https://bugzilla.mozilla.org/show_bug.cgi?id=1912228 for details.`
     17 );
     18 
     19 // Third-party origin we need to request storage access for.
     20 const STORAGE_ACCESS_ORIGIN = "https://login.aliexpress.com";
     21 
     22 document.documentElement.addEventListener(
     23  "click",
     24  e => {
     25    const { target, isTrusted } = e;
     26    if (!isTrusted) {
     27      return;
     28    }
     29    const i18nButton = target.closest('div[class^="ship-to--menuItem--"]');
     30    if (!i18nButton) {
     31      return;
     32    }
     33 
     34    console.warn(
     35      "Calling the Storage Access API on behalf of " + STORAGE_ACCESS_ORIGIN
     36    );
     37    e.stopPropagation();
     38    e.preventDefault();
     39    document
     40      .requestStorageAccessForOrigin(STORAGE_ACCESS_ORIGIN)
     41      .finally(() => {
     42        target.click();
     43      });
     44  },
     45  true
     46 );