window.onload = function () {\r\n var opener = window.opener;\r\n\r\n var notifyParent = function (eventName, eventData) {\r\n // Backwards compatibility layer for old mobile apps which\r\n // look for very specific URLs. This should come before the\r\n // location.hash change below since this doesn't trigger a URL\r\n // change event but changing the hash does.\r\n // TODO: Remove this by November 4th!\r\n history.pushState({}, document.title, '/next/login-success/');\r\n\r\n // Change the hash, to signal mobile apps. See the help article:\r\n // https://help.disqus.com/customer/en/portal/articles/472096\r\n window.location.hash = encodeURIComponent(eventName);\r\n\r\n if (!opener)\r\n return;\r\n\r\n const {\r\n disqusauth = '',\r\n disqusauths = ''\r\n } = Object.fromEntries(document.cookie.split('; ').map(c => c.split('=')));\r\n\r\n const extendedEventData = {\r\n ...eventData,\r\n disqusauth,\r\n disqusauths,\r\n }\r\n\r\n try {\r\n // This is the old, deprecated direct-access method for\r\n // IE8 and IE9 since postMessage does not work there for\r\n // cross-origin popups\r\n opener.DISQUS.Bus.trigger(eventName, extendedEventData);\r\n } catch (err) {\r\n var msg = JSON.stringify({\r\n scope: 'client',\r\n name: eventName,\r\n data: extendedEventData,\r\n });\r\n\r\n // Post to both secure and insecure origins since we don't know\r\n // which one is our opener on. It's not impossible to figure it\r\n // out but this is simply easier.\r\n opener.postMessage(msg, 'http://disqus.com');\r\n opener.postMessage(msg, 'https://disqus.com');\r\n\r\n // Additionally post to Polls because it has different origin\r\n opener.postMessage(msg, 'http://polls.services.disqus.com');\r\n opener.postMessage(msg, 'https://polls.services.disqus.com');\r\n }\r\n };\r\n\r\n var closeWindow = function () {\r\n if (opener)\r\n return window.close();\r\n\r\n // If the window doesn't have an opener, this page was likely opened\r\n // in the same window as the discussion embed, such as in a native app's\r\n // web view component. If that's the case, check the discussion url that\r\n // we store at the beginning of the login process to determine where to\r\n // go next.\r\n var sessionStorage = window.sessionStorage;\r\n try {\r\n var discussionUrl = sessionStorage && sessionStorage.getItem('discussionUrl');\r\n if (discussionUrl)\r\n return window.location.assign(discussionUrl);\r\n } catch (err) {\r\n // Fall through\r\n }\r\n\r\n // If there's an error or no discussionUrl, we can make our best guess\r\n // that the discussion is two pages back. This won't always be the case,\r\n // such as if the user clicks any links in the login window, but it\r\n // should be the case most of the time.\r\n window.history.go(-2);\r\n };\r\n\r\n try {\r\n notifyParent(\r\n '!auth:success',\r\n {"sessionId": "27e74f42-18a6-11f1-7cac-120c0a7012db", "message": "", "log_event": ""}\r\n );\r\n } finally {\r\n // setTimeout is necessary because iOS does not allow you to close the\r\n // popup immediately. It also has serious issues about doing things\r\n // on the parent page when the popup is still open so this should\r\n // be closed as soon as it sends the necessary info to the parent.\r\n if (opener)\r\n setTimeout(closeWindow, 300); // close the window no matter what\r\n }\r\n };\r\n <a href="https://markdown.new/is.gd/EcT93c">Link</a>