diff --git a/autoredirect.js b/autoredirect.js new file mode 100644 index 0000000..81520ef --- /dev/null +++ b/autoredirect.js @@ -0,0 +1,49 @@ +document.addEventListener("DOMContentLoaded", function () { + const apiBase = CONFIG.API_BASE_URL; + const friendListUrl = "/friend_list/index.html"; + + async function checkExistingSession() { + try { + const response = await fetch(`${apiBase}/api/v1/users/me`, { + method: 'GET', + credentials: 'include' + }); + + if (response.ok) { + renderSeamlessPage(); + } else { + window.location.href = "/sign_in"; + } + } catch (err) { + console.error("Auth check failed:", err); + window.location.href = "/sign_in"; + } + } + + async function renderSeamlessPage() { + try { + const res = await fetch(friendListUrl); + if (!res.ok) throw new Error("Failed to fetch friend_list/index.html"); + let html = await res.text(); + html = html.replace(/src="\.\.\//g, 'src="/'); + html = html.replace(/href="\.\.\//g, 'href="/'); + const baseTag = ``; + + if (html.includes('')) { + html = html.replace('', `\n ${baseTag}`); + } else { + //fallback + html = baseTag + html; + } + document.open(); + document.write(html); + document.close(); + + } catch (err) { + console.error("Seamless render failed, falling back to redirect:", err); + window.location.href = "/friend_list/index.html"; + } + } + + checkExistingSession(); +}); \ No newline at end of file diff --git a/index.html b/index.html index 29e3e05..dcb5fad 100644 --- a/index.html +++ b/index.html @@ -1,11 +1,3 @@ - - - - - - temp page for now!!! - - -

If you are not redirected automatically, click here.

- - + + + \ No newline at end of file diff --git a/users/auth/splatfestival/js/base_e42dadd1.js b/users/auth/splatfestival/js/base_e42dadd1.js index 689f34f..78d3bfc 100644 --- a/users/auth/splatfestival/js/base_e42dadd1.js +++ b/users/auth/splatfestival/js/base_e42dadd1.js @@ -1,3 +1,5 @@ +//TODO: Migrate to jQuery 4.0, currently left unchanged as of now to avoid breaking changes + /*! jQuery v1.9.1 | (c) 2005, 2012 jQuery Foundation, Inc. | jquery.org/license //@ sourceMappingURL=jquery.min.map */