Skip to content

Instantly share code, notes, and snippets.

@xvnpw
Created April 23, 2020 10:48
Show Gist options
  • Save xvnpw/36703fcb9044a77a90c6d557408666b4 to your computer and use it in GitHub Desktop.
Save xvnpw/36703fcb9044a77a90c6d557408666b4 to your computer and use it in GitHub Desktop.
<input style=width:100% autocomplete=off id=url><br>
<select id=mode>
<option value=none>No security</option>
<option value=blacklist>Blacklist</option>
<option value=whitelist>Whitelist</option>
</select>
<hr>
<h2>Profile page</h2>
<p>My profile page url: <a id=addr></a></p>
<script>
url.oninput = mode.onchange = ev => {
let u = url.value;
let m = mode.value;
if (m === 'blacklist') {
if (u.match(/^javascript:/)) {
u = 'unsafe:' + u;
}
} else if (m === 'whitelist') {
if (!u.match(/^https?:\/\//i)) {
u = 'unsafe:' + u;
}
}
addr.href = addr.textContent = u;
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment