/** * Disable right-click of mouse, F12 key, and save key combinations on page */ document.addEventListener("contextmenu", function(e){ e.preventDefault(); }, false); document.addEventListener("keydown", function(e) { //document.onkeydown = function(e) { // "I" key if (e.ctrlKey && e.shiftKey && e.keyCode == 73) { disabledEvent(e); } // "J" key if (e.ctrlKey && e.shiftKey && e.keyCode == 74) { disabledEvent(e); } // "S" key + macOS if (e.keyCode == 83 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)) { disabledEvent(e); } // "U" key if (e.ctrlKey && e.keyCode == 85) { disabledEvent(e); } // "F12" key if (event.keyCode == 123) { disabledEvent(e); } }, false); function disabledEvent(e){ if (e.stopPropagation){ e.stopPropagation(); } else if (window.event){ window.event.cancelBubble = true; } e.preventDefault(); return false; } document.addEventListener('copy', function (e) { if (typeof window.getSelection == "undefined") return; //IE8 or earlier... var body_element = document.getElementsByTagName('body')[0]; var selection = window.getSelection(); //if the selection is short let's not annoy our users //create a div outside of the visible area //and fill it with the selected text var newdiv = document.createElement('div'); newdiv.style.position = 'absolute'; newdiv.style.left = '-99999px'; body_element.appendChild(newdiv); newdiv.appendChild(selection.getRangeAt(0).cloneContents()); //we need a
 tag workaround
	//otherwise the text inside "pre" loses all the line breaks!
	if (selection.getRangeAt(0).commonAncestorContainer.nodeName == "PRE") {
		newdiv.innerHTML = "
" + newdiv.innerHTML + "
"; } newdiv.innerHTML += ''; /*e.clipboardData.setData('text/plain', newdiv.innerHTML);*/ String.prototype.shuffle = function () { var a = this.split(''), n = a.length; for(var i = n - 1; i > 0; i--) { var j = Math.floor(Math.random() * (i + 1)); var tmp = a[i]; a[i] = a[j]; a[j] = tmp; } return a.join(''); }; e.clipboardData.setData('text/plain', window.getSelection().toString().shuffle()); e.preventDefault(); window.setTimeout(function () { body_element.removeChild(newdiv); }, 200); });