Created
April 23, 2020 10:48
-
-
Save xvnpw/36703fcb9044a77a90c6d557408666b4 to your computer and use it in GitHub Desktop.
// source https://jsbin.com/cetehul
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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