Files
Website/js/protection.js
2025-08-17 14:16:58 +02:00

188 Zeilen
5.8 KiB
JavaScript

/**
* Website Protection Script
* Prevents copying, downloading, and inspection of website content
*/
(function() {
'use strict';
// Disable right-click context menu
document.addEventListener('contextmenu', function(e) {
e.preventDefault();
return false;
});
// Disable text selection
document.addEventListener('selectstart', function(e) {
e.preventDefault();
return false;
});
// Disable drag
document.addEventListener('dragstart', function(e) {
e.preventDefault();
return false;
});
// Disable copy
document.addEventListener('copy', function(e) {
e.preventDefault();
return false;
});
// Disable cut
document.addEventListener('cut', function(e) {
e.preventDefault();
return false;
});
// Disable paste
document.addEventListener('paste', function(e) {
e.preventDefault();
return false;
});
// Disable print
window.addEventListener('beforeprint', function(e) {
e.preventDefault();
return false;
});
// Detect and block DevTools
let devtools = {open: false, orientation: null};
const threshold = 160;
const emitEvent = (state, orientation) => {
if (state) {
console.clear();
document.body.style.display = 'none';
document.body.innerHTML = '<div style="display:flex;justify-content:center;align-items:center;height:100vh;background:#000;color:#fff;font-family:Inter,sans-serif;"><h1>Zugriff verweigert</h1></div>';
}
};
setInterval(() => {
if (window.outerHeight - window.innerHeight > threshold ||
window.outerWidth - window.innerWidth > threshold) {
if (!devtools.open) {
emitEvent(true, null);
devtools.open = true;
}
} else {
if (devtools.open) {
emitEvent(false, null);
devtools.open = false;
}
}
}, 500);
// Disable F12, Ctrl+Shift+I, Ctrl+Shift+J, Ctrl+U, Ctrl+S
document.addEventListener('keydown', function(e) {
// F12
if (e.keyCode === 123) {
e.preventDefault();
return false;
}
// Ctrl+Shift+I (DevTools)
if (e.ctrlKey && e.shiftKey && e.keyCode === 73) {
e.preventDefault();
return false;
}
// Ctrl+Shift+J (Console)
if (e.ctrlKey && e.shiftKey && e.keyCode === 74) {
e.preventDefault();
return false;
}
// Ctrl+U (View Source)
if (e.ctrlKey && e.keyCode === 85) {
e.preventDefault();
return false;
}
// Ctrl+S (Save)
if (e.ctrlKey && e.keyCode === 83) {
e.preventDefault();
return false;
}
// Ctrl+A (Select All)
if (e.ctrlKey && e.keyCode === 65) {
e.preventDefault();
return false;
}
// Ctrl+C (Copy)
if (e.ctrlKey && e.keyCode === 67) {
e.preventDefault();
return false;
}
// Ctrl+X (Cut)
if (e.ctrlKey && e.keyCode === 88) {
e.preventDefault();
return false;
}
// Ctrl+V (Paste)
if (e.ctrlKey && e.keyCode === 86) {
e.preventDefault();
return false;
}
});
// Disable image dragging
const images = document.getElementsByTagName('img');
for (let i = 0; i < images.length; i++) {
images[i].addEventListener('dragstart', function(e) {
e.preventDefault();
return false;
});
images[i].addEventListener('mousedown', function(e) {
e.preventDefault();
return false;
});
}
// Clear console periodically
setInterval(function() {
console.clear();
console.log('%cSicherheitswarnung!', 'color: red; font-size: 30px; font-weight: bold;');
console.log('%cDiese Browser-Funktion ist für Entwickler vorgesehen. Unbefugter Zugriff ist untersagt.', 'color: red; font-size: 16px;');
}, 1000);
// Detect console.log override attempts
const originalLog = console.log;
console.log = function() {
originalLog.apply(console, arguments);
console.clear();
};
// Disable text highlighting with CSS
const style = document.createElement('style');
style.innerHTML = `
* {
-webkit-user-select: none !important;
-moz-user-select: none !important;
-ms-user-select: none !important;
user-select: none !important;
-webkit-touch-callout: none !important;
-webkit-user-drag: none !important;
}
img {
pointer-events: none !important;
-webkit-user-drag: none !important;
-khtml-user-drag: none !important;
-moz-user-drag: none !important;
-o-user-drag: none !important;
user-drag: none !important;
}
@media print {
body {
display: none !important;
}
}
`;
document.head.appendChild(style);
// Protection against automated tools
if (window.automation || window.callPhantom || window._phantom || window.__nightmare || window.WebDriverException || document.__webdriver_evaluate || document.__selenium_evaluate || document.__webdriver_script_function || document.__webdriver_script_func || document.__webdriver_script_fn || document.__fxdriver_evaluate || document.__driver_unwrapped || document.__webdriver_unwrapped || document.__driver_evaluate || document.__selenium_unwrapped || document.__fxdriver_unwrapped) {
document.body.style.display = 'none';
document.body.innerHTML = '';
}
})();