Created
August 16, 2024 02:45
-
-
Save joshua-koehler/171a68a673916813a511baa5804dd799 to your computer and use it in GitHub Desktop.
If the user's time is Sabbath, or it's Sabbath in us-east, then replace the DOM content with a closed page and stop loading other resources. Use this script just underneath the opening html tag so it evaluates first.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const style=`.container { | |
| display: flex; | |
| justify-content: center; /* horizontal centering */ | |
| align-items: center; /* vertical centering */ | |
| height: 2em; /* define a height for demonstration purposes */ | |
| }` | |
| const sabbath_closed_html=` | |
| <html> | |
| <style>${style}</style> | |
| <body> | |
| <h1 class='container'>Closed for the Lord's Day</h1> | |
| <h2 class='container'>This site is closed on the Christian Sabbath.</h2> | |
| </body> | |
| </html>`; | |
| function close() { | |
| const d = new Date(); | |
| // is Sabbath in local time or east coast US | |
| const isSabbath = d.getDay() === 0 || (d.getUTCDay() === 0 && d.getUTCHours() > 5) || (d.getUTCDay() === 1 && d.getUTCHours() < 5); | |
| if(isSabbath){ | |
| document.documentElement.innerHTML = sabbath_closed_html; | |
| window.stop(); | |
| } | |
| } | |
| close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment