diff --git a/404.html b/404.html index 5ee2f27..5685125 100644 --- a/404.html +++ b/404.html @@ -2,6 +2,18 @@ + diff --git a/accessibility/index.html b/accessibility/index.html index a89c31d..7b2dfd3 100644 --- a/accessibility/index.html +++ b/accessibility/index.html @@ -2,6 +2,18 @@ + diff --git a/get-help/index.html b/get-help/index.html index 63c3dc9..5bec9c4 100644 --- a/get-help/index.html +++ b/get-help/index.html @@ -2,6 +2,18 @@ + diff --git a/get-involved/index.html b/get-involved/index.html index 014fb4d..c5bed5c 100644 --- a/get-involved/index.html +++ b/get-involved/index.html @@ -2,6 +2,18 @@ + diff --git a/index.html b/index.html index 61d9fd8..4651c98 100644 --- a/index.html +++ b/index.html @@ -2,6 +2,18 @@ + diff --git a/privacy/index.html b/privacy/index.html index 2bd7481..842bc73 100644 --- a/privacy/index.html +++ b/privacy/index.html @@ -2,6 +2,18 @@ + diff --git a/script.js b/script.js index 00693b8..859b749 100644 --- a/script.js +++ b/script.js @@ -3,13 +3,46 @@ document.documentElement.classList.replace("no-js", "js"); const QUICK_EXIT_URL = "https://www.google.com/"; +const QUICK_EXIT_KEY = "quick-exit"; const STAGING_HOST = "whispersoflhj.cosmicallycreative.com"; const MOBILE_NAV_QUERY = window.matchMedia("(max-width: 88em)"); +function navigationType() { + const navigation = performance.getEntriesByType("navigation")[0]; + return navigation ? navigation.type : ""; +} + function quickExit() { + try { + // Remember the exit for this tab so Back cannot reopen the site. + sessionStorage.setItem(QUICK_EXIT_KEY, "1"); + } catch (error) {} + + document.documentElement.hidden = true; + if (document.body) document.body.replaceChildren(); window.location.replace(QUICK_EXIT_URL); } +try { + if (navigationType() === "back_forward" && sessionStorage.getItem(QUICK_EXIT_KEY) === "1") { + document.documentElement.hidden = true; + window.location.replace(QUICK_EXIT_URL); + } +} catch (error) {} + +window.addEventListener("pageshow", (event) => { + if (!event.persisted) return; + + try { + if (sessionStorage.getItem(QUICK_EXIT_KEY) !== "1") return; + } catch (error) { + return; + } + + document.documentElement.hidden = true; + window.location.replace(QUICK_EXIT_URL); +}); + document.querySelectorAll(".quick-exit").forEach((link) => { link.addEventListener("click", (event) => { event.preventDefault(); @@ -31,6 +64,29 @@ document.addEventListener("keydown", (event) => { quickExit(); }); +document.addEventListener("click", (event) => { + if (event.defaultPrevented || event.button !== 0) return; + if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return; + + const link = event.target.closest("a[href]"); + if (!link || link.classList.contains("quick-exit")) return; + if (link.target && link.target !== "_self") return; + if (link.hasAttribute("download")) return; + + let url; + try { + url = new URL(link.href); + } catch (error) { + return; + } + + if (url.origin !== window.location.origin) return; + if (url.pathname === window.location.pathname && url.search === window.location.search && url.hash) return; + + event.preventDefault(); + window.location.replace(url.href); +}); + document.querySelectorAll(".nav").forEach((nav) => { const toggle = nav.querySelector(".mobile-nav-toggle"); const toggleLabel = toggle?.querySelector(".mobile-nav-toggle-label"); diff --git a/shop-church/index.html b/shop-church/index.html index 576d8ef..fd22c26 100644 --- a/shop-church/index.html +++ b/shop-church/index.html @@ -2,6 +2,18 @@ + diff --git a/staying-safe/index.html b/staying-safe/index.html index 2b093ed..dce99a5 100644 --- a/staying-safe/index.html +++ b/staying-safe/index.html @@ -2,6 +2,18 @@ + diff --git a/talitha-koum/index.html b/talitha-koum/index.html index d5bf42a..b80a430 100644 --- a/talitha-koum/index.html +++ b/talitha-koum/index.html @@ -2,6 +2,18 @@ + diff --git a/what-we-do/index.html b/what-we-do/index.html index 0d5d06c..6f4f1c4 100644 --- a/what-we-do/index.html +++ b/what-we-do/index.html @@ -2,6 +2,18 @@ + diff --git a/who-we-are/index.html b/who-we-are/index.html index fefa360..5016aec 100644 --- a/who-we-are/index.html +++ b/who-we-are/index.html @@ -2,6 +2,18 @@ +