MediaWiki:Common.js: Difference between revisions

fixed the mobile redirect so it actually sticks now
Tag: Reverted
cleaned up some dead code from the mobile fix
Tag: Reverted
Line 7: Line 7:
// redirecting.
// redirecting.
//
//
// The real loop-guard is the cookie this site's toggle actually sets
// The server does set a loop-guard cookie on the toggle ("stopMobileRedirect"),
// (confirmed by testing: "stopMobileRedirect=true", not the generic
// but it's HttpOnly (confirmed by testing), so client-side JS can never
// MobileFrontend "mf_useformat" name assumed earlier) since it's set by
// actually read it - that check would always be dead code. sessionStorage
// the server and survives across tabs/sessions. sessionStorage is only a
// is the only guard we can use here, wrapped in its own try/catch so a
// secondary backstop, wrapped in its own try/catch, so that browsers which
// browser that blocks storage access (some in-app/embedded browsers do)
// block storage access (common in some in-app/embedded browsers) don't
// doesn't cancel the whole redirect and strand the user on Minerva.
// silently cancel the whole redirect and strand the user on Minerva.
(function () {
(function () {
   try {
   try {
     if (!document.body || !document.body.classList.contains('skin-minerva')) return;
     if (!document.body || !document.body.classList.contains('skin-minerva')) return;
    if (document.cookie.indexOf('stopMobileRedirect=true') !== -1) return;
     var alreadyTried = false;
     var alreadyTried = false;
     try { alreadyTried = !!sessionStorage.getItem('wovForcedDesktop'); } catch (e) {}
     try { alreadyTried = !!sessionStorage.getItem('wovForcedDesktop'); } catch (e) {}