Advertisement
KrimsN

Untitled

Jun 4th, 2019
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function kill_ctrl_key_combo(e) {
  2.     var forbiddenKeys = new Array('a', 'c', 'x', 's', 'u');
  3.     var key;
  4.     var isCtrl;
  5.     if (window.event) {
  6.         key = window.event.keyCode;
  7.         if (window.event.ctrlKey) isCtrl = true;
  8.         else isCtrl = false;
  9.     } else {
  10.         key = e.which;
  11.         if (e.ctrlKey) isCtrl = true;
  12.         else isCtrl = false;
  13.     }
  14.     //if ctrl is pressed check if other key is in forbidenKeys array
  15.     if (isCtrl) {
  16.         for (i = 0; i < forbiddenKeys.length; i++) { //case-insensitive comparation
  17.             if (forbiddenKeys[i].toLowerCase() == String.fromCharCode(key).toLowerCase()) {
  18.                 return false;
  19.             }
  20.         }
  21.     }
  22.     return true;
  23. }
  24.  
  25. function disable_selection(target) {
  26.     if (typeof target.style.MozUserSelect != "undefined") {
  27.         target.style.MozUserSelect = "none";
  28.     }
  29.     target.style.cursor = "default";
  30. }
  31.  
  32. function double_mouse(e) {
  33.     if (e.which == 2 || e.which == 3) {
  34.         return false;
  35.     }
  36.     return true;
  37. }
  38.  
  39. function enable_protection() {
  40.     disable_selection(document.body); //These will disable selection on the page
  41.     document.captureEvents(Event.MOUSEDOWN);
  42.     document.onmousedown = double_mouse; //These will disable double mouse on the page
  43.     document.oncontextmenu = function() {
  44.         return false;
  45.     }; //These will disable right click on the page
  46.     document.onkeydown = kill_ctrl_key_combo;
  47. }
  48.  
  49. window.onload = function() { //These will enable protection on the page
  50.     enable_protection();
  51. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement