Skip to content

Instantly share code, notes, and snippets.

View avamariadesign's full-sized avatar

avamariadesign

View GitHub Profile
@KaiCode2
KaiCode2 / SquarespaceConfirmAgeInjection.js
Last active February 22, 2022 04:01
A simple snippet of code to add Squarespace website to add an age confirmation pop-up. To add, go to Setting > Advanced > Code Injection and add the below into the header. Note: Change the imageUrl (line #24) and change the ageGateUrl (lines #43, #51) to redirected underage visitors
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@9"></script>
<script type="text/javascript">
//document.onload = checkAge(document.URL);
function setCookie(name, value, days) {
var d = new Date();
d.setTime(d.getTime() + (days * 24 * 60 * 60 * 1000));
var expires = "expires="+d.toGMTString();
document.cookie = name + "=" + value + "; " + expires + "; path=/";
}
@jupitercow
jupitercow / squarespace-age-gate.js
Last active November 17, 2022 19:40
Squarespace Age Gate. Add this code just to the Age Gate page. This is usually a "Cover Page" under Pages > Not Linked. Click the gear icon, go to Advanced tab in the popup, paste this code. This sets the cookie and handles the redirect back to the requested content.
<script>
/*
Squarespace Age Gate.
- Create a "Cover Page" under Pages > Not Linked.
- Click the gear icon, go to Advanced tab in the popup, paste this code.
- This sets the cookie and handles the redirect back to the requested content.
- On the age gate page, you have to create a button that has "#legal" as the link or href. It is what turns off the age gate.
- Elsewhere on the site, you can test for the cookie (legal), and if not set, rediret to the age gate Cover Page (example at the bottom).
*/