A lightweight client-side domain restriction system that allows you to authorize, block, and validate domains where your script is allowed to run.
Useful for basic protection, form validation, license-like checks, and preventing casual misuse of scripts.
⚠️ Note: This is not server-side security. It is intended for basic control and deterrence, not for high-security use cases.
https://cdn--skunkplatform.netlify.app/free/scripts/domain-restriction.js<script src="https://cdn--skunkplatform.netlify.app/free/scripts/domain-restriction.js"></script>Once loaded, the script exposes a global object:
window.sp_domain_restrictionsp_domain_restriction = {
matchDomain,
addAuthorizedDomain,
addBannedDomain,
security,
_data
}sp_domain_restriction._data = {
authorizedDomains: {},
bannedDomains: {},
settings: {
blockAllUnauthorizedSubdomains: false,
blockAllUnauthorizedDomains: true
}
}| Setting | Description |
|---|---|
blockAllUnauthorizedDomains |
Blocks all domains not explicitly authorized |
blockAllUnauthorizedSubdomains |
Blocks subdomains unless explicitly allowed |
await sp_domain_restriction.addAuthorizedDomain(
"example.com",
"MY_SECRET_PASSWORD",
["token", "id"]
);Explanation:
example.com→ allowed domain"token", "id"→ allowed URL parameters (?token=,?id=)
If you don’t want to restrict parameters:
await sp_domain_restriction.addAuthorizedDomain(
"example.com",
"MY_SECRET_PASSWORD"
);await sp_domain_restriction.addBannedDomain(
"malicious-site.com",
"MY_SECRET_PASSWORD"
);Any domain added here will always be blocked.
This function must be called manually. The script does nothing automatically unless you validate the domain.
const allowed = await sp_domain_restriction.matchDomain(
window.location.hostname,
[...new URLSearchParams(window.location.search).keys()]
);
if (!allowed) {
document.body.innerHTML = "403 - Forbidden";
throw new Error("Unauthorized domain");
}const result = await sp_domain_restriction.security.addGenerated({
domain: "example.com"
});
console.log(result.generatedPassword);await sp_domain_restriction.security.add({
domain: "example.com",
password: "StrongPassword123!"
});(async () => {
await sp_domain_restriction.addAuthorizedDomain(
"skunkplatform.netlify.app",
"SKUNK_SECURE_2026",
["token"]
);
const isAllowed = await sp_domain_restriction.matchDomain(
location.hostname,
[...new URLSearchParams(location.search).keys()]
);
if (!isAllowed) {
document.body.innerHTML = "Access denied";
throw new Error("Blocked domain");
}
console.log("Domain authorized");
})();- This system is client-side only
- JavaScript can be modified by advanced users
- Do not rely on this for sensitive data protection
- Basic license checks
- Form/domain validation
- Hotlink prevention
- Casual script misuse prevention
- Authentication
- Payment validation
- Sensitive data protection
Free to use. Attribution appreciated but not required.
SkunkPlatform Domain Restriction Script