Skip to content

Instantly share code, notes, and snippets.

@0x00000FF
Created September 14, 2020 18:00
Show Gist options
  • Save 0x00000FF/bfb0abf868ebb79a8068cfd1ef715f06 to your computer and use it in GitHub Desktop.
Save 0x00000FF/bfb0abf868ebb79a8068cfd1ef715f06 to your computer and use it in GitHub Desktop.
Prevents printing, context menu, and copy and developer console
<style>
@media print { * { display: none } }
</style>
<script>
document.addEventListener("contextmenu", function (e) {
e.preventDefault();
});
document.addEventListener("mousedown", function (e) {
e.preventDefault();
});
document.addEventListener("click", function(e) {
if (e.button == 2) e.preventDefault();
});
document.addEventListener("keydown", function(e) {
if (e.keyCode == 123) e.preventDefault();
else if (e.ctrlKey && e.keyCode == 67) e.preventDefault();
else if (e.ctrlKey && e.keyCode == 83) e.preventDefault();
else if (e.ctrlKey && e.keyCode == 80) e.preventDefault();
else if (e.ctrlKey && e.shiftKey && e.keyCode == 73) e.preventDefault();
});
document.querySelector("script").remove();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment