window.open method so we can detect oauth related popups. const origOpen = window.wrappedJSObject.open; Object.defineProperty(window.wrappedJSObject, "open", { value: exportFunction((url, ...args) => { // Filter oauth popups. if (!url.startsWith(OAUTH_PATH_PREFIX)) { return origOpen(url, ...args); } // Request storage access for Kinja. document.requestStorageAccessForOrigin(STORAGE_ACCESS_ORIGIN).then(() => { origOpen(url, ...args); }); // We don't have the window object yet which window.open returns, since the // sign-in flow is dependent on the async storage access request. This isn't // a problem as long as the website does not consume it. return null; }, window), }); PK