tor-browser

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

jira-zendesk-support.js (1418B)


      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 console.warn(
      8  `When adding Zendesk support in Jira, Firefox calls the Storage Access API on behalf of the site. See https://bugzilla.mozilla.org/show_bug.cgi?id=1774592 for details.`
      9 );
     10 
     11 /**
     12 * The Jira Zendesk plugin requires storage access to the jiraplugin.zendesk.com
     13 * domain. This shim intercepts clicks on the Zendesk support button on the APP
     14 * marketplace page  and requests storage access for the domain.
     15 */
     16 
     17 const STORAGE_ACCESS_ORIGIN = "https://jiraplugin.zendesk.com";
     18 
     19 document.documentElement.addEventListener(
     20  "click",
     21  e => {
     22    const { target, isTrusted } = e;
     23    if (!isTrusted) {
     24      return;
     25    }
     26    const button = target.closest(
     27      "a[href*='/jira/marketplace/discover/app/zendesk_for_jira']"
     28    );
     29    if (!button) {
     30      return;
     31    }
     32 
     33    console.warn(
     34      "Calling the Storage Access API on behalf of " + STORAGE_ACCESS_ORIGIN
     35    );
     36    button.disabled = true;
     37    e.stopPropagation();
     38    e.preventDefault();
     39    document
     40      .requestStorageAccessForOrigin(STORAGE_ACCESS_ORIGIN)
     41      .then(() => {
     42        button.disabled = false;
     43        target.click();
     44      })
     45      .catch(() => {
     46        button.disabled = false;
     47      });
     48  },
     49  true
     50 );