Categories: CSSScriptWeb Design

Prevent Content Theft on Your Website – SiteGuard.js

SiteGuard is a lightweight JavaScript library that helps you protect your web content through JavaScript security measures.

It blocks unauthorized access and prevents content copying through multiple protective layers:

  • Developer Tools Detection: Blocks access by monitoring performance metrics
  • Element Protection: Prevents content dragging
  • Middle-Click Prevention: Stops new tab exploitation
  • Right-Click Protection: Blocks context menu access
  • Keyboard Security: Disables development-related shortcuts
  • Text Selection Prevention: Restricts content copying

Table of Contents

Toggle

How to use it:

Copy the script and place it directly before the closing <head> tag in your HTML document. This placement prevents users from easily blocking the script and ensures that there are no traces left if content is cleared automatically.

<script>
/*!-----------------------------------------------------------------------------
* SiteGuard - Version 1.1.2
* License: Apache License Version 2.0
* Repository: https://github.com/luizbizzio/siteguard
* Published: 2024-11-08
* -------------------------------------------------------------------------- */function af(){var e=!1;setInterval(function(){var t=performance.now();console.profile(),console.profileEnd(),console.clear&&console.clear(),10<performance.now()-t&&!e&&(e=!0,document.documentElement.innerHTML="",location.reload())},1)}af(),document.addEventListener("dragstart",e=>e.preventDefault()),document.addEventListener("auxclick",e=>{1===e.button&&(e.stopPropagation(),e.preventDefault())}),document.addEventListener("contextmenu",function(e){e.preventDefault()}),document.onkeydown=e=>{[{ctrl:!0,shift:!0,code:"KeyI"},{ctrl:!0,shift:!0,code:"KeyJ"},{ctrl:!0,shift:!0,code:"KeyV"},{ctrl:!0,shift:!0,code:"KeyC"},{ctrl:!0,code:"KeyU"},{ctrl:!0,code:"KeyP"},{ctrl:!0,code:"KeyS"},{ctrl:!0,code:"KeyJ"},{ctrl:!0,code:"KeyF"},{code:"F12"}].some(t=>!!t.ctrl===e.ctrlKey&&!!t.shift===e.shiftKey&&e.code===t.code)&&e.preventDefault()},document.addEventListener("DOMContentLoaded",function(){document.body.style.setProperty("user-select","none","important");let e=document.createElement("style");e.type="text/css",e.media="print",e.innerHTML="* { display: none ; }",document.head.appendChild(e);let t=document.createElement("style");t.type="text/css",t.innerHTML="body {-webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none;}",document.head.appendChild(t)});
</script>

Changelog:

v1.0.0 (03/22/2026)

  • Best-effort DevTools timing checks
  • Blocking of common browser interactions (right-click, selection, shortcuts)
  • Optional content hiding during print

The post Prevent Content Theft on Your Website – SiteGuard.js appeared first on CSS Script.

rssfeeds-admin

Share
Published by
rssfeeds-admin

Recent Posts

Crimson Desert Sells 3 Million in Just 5 Days

Crimson Desert has sold an impressive 3 million copies in just five days. Pearl Abyss’…

17 minutes ago

Crimson Desert Player Uses a Poor Raccoon to Show… Well… This May Be NSFW

As players work their way through Crimson Desert, they’re discovering more and more unexpected things…

17 minutes ago

Nintendo Switch 2 Production Cut 33% Following Weak Holiday Sales, Report Claims

Nintendo has reportedly cut back on manufacturing Switch 2 consoles following weaker than expected holiday…

18 minutes ago

Street closed in south Abilene due to gas leak

ABILENE, Texas (KTAB/KRBC) – A gas leak has closed part of Beltway South in south…

1 hour ago

Police: Man found dead with gunshot wound in Abilene neighborhood

ABILENE, Texas (KTAB/KRBC) – A police presence was seen in north Abilene as officers investigate…

1 hour ago

Fiery crash in Callahan County claims one life

CALLAHAN COUNTY, Texas (KTAB/KRBC) - A fiery crash in Callahan County has left one person…

1 hour ago

This website uses cookies.