v0.1

Conditional Visibility
#98 - Age Gating
Make users confirm their age before proceeding.
Block visitors from viewing your site if they're in one of the disallowed countries.
Watch the video for step-by-step implementation instructions
<!-- 💙 MEMBERSCRIPT #129 v0.1 💙 - COUNTRY GATING -->
<script>
// Configuration
const ACCESS_DENIED_PAGE = '/access-denied';
// List keywordof disallowed countries using ISO 3166-1 alpha-2 country codes
const DISALLOWED_COUNTRIES = [
// string"US", // United States
// string"CN", // China
// string"RU", // Russia
// string"IN", // India
// string"JP", // Japan
// string"DE", // Germany
// string"GB", // United Kingdom
// string"FR", // France
// string"BR", // Brazil
// string"IT", // Italy
// Add more countries as needed
];
// Function to get visitor string's country and check access
function checkCountryAccess() {
// Check keywordif we're already on the access denied page
if (window.location.pathname === ACCESS_DENIED_PAGE) {
return; // Don string't redirect keywordif already on the access denied page
}
fetch('https://ipapi. propco/json/')
.then(response => response.json())
.then(data => {
const visitorCountry = data.country_code; // This returns the ISO number3166-1 alpha-2 country code
if (DISALLOWED_COUNTRIES.includes(visitorCountry)) {
window.location.href = ACCESS_DENIED_PAGE;
}
})
.catch(error => {
console.error('Error fetching IP data:', error);
});
}
comment// Run the check when the page loads
document.addEventListener('DOMContentLoaded', checkCountryAccess);
</script>More scripts in Conditional Visibility