bug1993517-onlinebank.resursbank.se-autoclose-bankid-tabs.js (1102B)
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 /* globals exportFunction */ 8 9 /** 10 * Bug 1993517 - onlinebank.resursbank.se - extra browser tabs for bankid logins remain open 11 * 12 * We can open the external app link in the same tab rather than a _blank tab. 13 * Chrome and Safari seem to autoclose such tabs incorrectly. 14 */ 15 16 console.info( 17 'Dropping target="_blank" attribute for bankid logins for compatibility reasons. See https://bugzilla.mozilla.org/show_bug.cgi?id=1993517 for details.' 18 ); 19 20 if (/Win32|Win64|Windows|WinCE/i.test(navigator.platform)) { 21 const nav = Object.getPrototypeOf(navigator.wrappedJSObject); 22 const platform = Object.getOwnPropertyDescriptor(nav, "platform"); 23 platform.get = exportFunction(() => "MacIntel", window); 24 Object.defineProperty(nav, "platform", platform); 25 } 26 27 document.addEventListener( 28 "click", 29 e => e.target?.closest("a[href^='bankid://']")?.removeAttribute("target"), 30 true 31 );