bug1889326-office365-email-handling-prompt-autohide.js (1155B)
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 1889326 - Office 365 email handling prompt autohide 9 * 10 * This site patch prevents the notification bar on Office 365 11 * apps from popping up on each page-load, offering to handle 12 * email with Outlook. 13 */ 14 15 /* globals exportFunction */ 16 17 const warning = 18 "Office 365 Outlook email handling prompt has been hidden. See https://bugzilla.mozilla.org/show_bug.cgi?id=1889326 for details."; 19 20 const localStorageKey = "mailProtocolHandlerAlreadyOffered"; 21 22 const proto = Object.getPrototypeOf(navigator).wrappedJSObject; 23 const { registerProtocolHandler } = proto; 24 const { localStorage } = window.wrappedJSObject; 25 26 proto.registerProtocolHandler = exportFunction(function (scheme, url, title) { 27 if (localStorage.getItem(localStorageKey)) { 28 console.info(warning); 29 return undefined; 30 } 31 registerProtocolHandler.call(this, scheme, url, title); 32 localStorage.setItem(localStorageKey, true); 33 return undefined; 34 }, window);