Skip to content

Instantly share code, notes, and snippets.

@Dan-Q
Created May 12, 2026 15:59
Show Gist options
  • Select an option

  • Save Dan-Q/09fa422b6c0936f92916f1908ca20d47 to your computer and use it in GitHub Desktop.

Select an option

Save Dan-Q/09fa422b6c0936f92916f1908ca20d47 to your computer and use it in GitHub Desktop.
Dated Site Closed Script
// DATED Simple Site Closer script v0.1
// This script shuts down certain pages automatically on some dates, expressed as regular expressions of ISO8601 datestamps!
// With thanks to MelonKing's original version: https://melonking.net/scripts/site-closer.js
//
// How to use:
// Just place this script in the head of any page you'd like to close!
// Make a page called closed.html and put your closed info on there!
//
// Add this code after you link the script:
// <script>
// sc.closedPage = "closed.html"; // Optional: change the closed page url
// sc.closedDays = [/^2026-01-01/, /^2026-12-../, /^....-..-01/]; // Specify the dates you'll be closed; syntax explained below
// shutItDown();
// </script>
//
// closedDays are all regular expressions. But you don't need to know regular expressions to use this!
// Just remember that each date looks like this:
// /^....-..-../
// yyyy mm dd
// Replace the dots with the yyyy-mm-dd date you want to be closed.
// Anything that's still a dot is a WILDCARD. So the following are all valid:
// /^2017-..-../ = closed all of 2017!
// /^....-..-01/ = closed on the first of every month
// /^....-04-01/ = closed every 1st of April
// /^2020-01-01/ = closed 1st of January 2020
//
// You can list as many dates as you want, separated by commas. Just remember the starting /^
// and the ending / - they're important!
let sc = {};
sc.closedPage = "closed.html";
sc.closedDays = [];
// Trigger this site closer!
function shutItDown() {
sc.dayNow = new Date().toISOString();
const closedToday = !!sc.closedDays.find(matcher=>today.match(matcher));
if(closedToday) {
console.log("Gordon Ramsay screams: Shut it Down!!!");
window.location.replace(sc.closedPage);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment