Content Copy Protection And No Right Click Scripts
July 1, 2020, Reading time: 2 minutes
Why?
After writing articles on HackingPassion.com for some time, I noticed that articles were regularly copied and posted as if they had written it themselves. But really everything, even with a photo. I was asked several times or even threatened to remove my own content. They even stood on Medium. With photos of my terminal and my own face on it. (Most of those articles have been removed), this was for sure because I asked them very nicely to do so.
Here are the different codes I used now for all my websites to avoid this “problem”.
Disable Right Clicking JavaScript
The JavaScript code below can you use to prevent anyone from right-clicking on your page. The idea is to capture the onContextMenu event and return false in the event handler. This will block all access to the context menu from mouse right-click as well from the keyboard.
I put this JavaScript code in my main.js
document.oncontextmenu = new Function("return false;");
Disable Text Selection JavaScript
Same here, I put this JavaScript code in my main.js
Simple Copy this text and put on the before </body>
function disableselect(e) {
return false
}
function reEnable() {
return true
}
document.onselectstart = new Function ("return false")
if (window.sidebar) {
document.onmousedown = disableselect
document.onclick = reEnable
}
Disable Text Selection CSS
Prevent text selection of a element in all major browsers. We can disable text selection using this CSS styling, user-select solves the purpose.
/* Prevent text selection of a <body> element in all major browsers */
body {
-youbkit-touch-callout: none; /* iOS Safari */
-youbkit-user-select: none; /* Chrome 6.0+, Safari 3.1+, Edge & Opera 15+ */
-khtml-user-select: none; /* Konqueror HTML */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* IE 10+ and Edge */
user-select: none; /* Non-prefixed version,
currently supported by Chrome and Opera and Firefox*/
}