Skip to content

Instantly share code, notes, and snippets.

@Juandresyn
Last active November 21, 2023 00:50
Show Gist options
  • Save Juandresyn/b6e2d0106d87279e681bd54c5089e758 to your computer and use it in GitHub Desktop.
Save Juandresyn/b6e2d0106d87279e681bd54c5089e758 to your computer and use it in GitHub Desktop.
electric-confetti-protection.js
const name = 'ele' + 'ctr' + 'ic' + 'con' + 'fet' + 'ti';
const allowedDomains = [
`${name}.co${'m'}`,
'shopify',
'myshopify',
'127.0.0.1',
'localhost',
'klarna'
];
const ProtectMsg = 'This Site is not allowed to be used on this domain. Please use the following domain: '
if (
window.location.hostname &&
!allowedDomains.some((domain) => window.location.hostname.includes(domain))
) {
alert(`${ProtectMsg} ${name}.com`);
document.querySelector(
'body',
).innerHTML = `<div style='position:relative; padding-bottom:calc(42.40% + 44px)'><iframe src="https://giphy.com/embed/SbN0WomN4S7Z7tpKOC" width="480" height="400" frameBorder="0" class="giphy-embed" allowFullScreen></iframe>
<h1>${ProtectMsg} <a href="https://${name}.com">${name}.com</a></h1>`;
const e = document.querySelector('head');
e.parentElement.removeChild(e);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment