Skip to content

musfiqurjahin/Clipboard-Blocker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

Text Selection and Copy Blocker

This script is designed to block users from selecting and copying text on a webpage. It prevents users from highlighting, right-clicking, or copying content from the site, thereby protecting your text-based content from being easily copied.

Features

  • Disable Text Selection: Prevents users from selecting text on the page, making it difficult to copy or highlight.
  • Disable Context Menu (Right-click): Blocks the right-click menu, which typically allows users to copy text or inspect elements.
  • Disable Copy Event: Even if users manage to highlight text (e.g., via dev tools), the copy function is disabled.
  • Cross-browser Compatibility: The script uses CSS properties with vendor prefixes to ensure compatibility across major browsers like Chrome, Safari, Firefox, and Internet Explorer.

How It Works

The script performs the following actions:

  • Injects a Style Block: A <style> element is dynamically created and injected into the page's <head>. This style block disables text selection using the user-select CSS property with vendor prefixes for browser compatibility.
  • Blocks Copy Event: The script listens for the "copy" event and prevents its default behavior, stopping users from copying text even if it’s somehow selected.
  • Disables Context Menu: The "contextmenu" event (triggered by right-clicking) is also blocked, preventing users from accessing the right-click options like "Copy" or "Inspect".

Usage

To use this script on your website:

  1. Copy the provided JavaScript code.
  2. Paste it into your HTML file within a <script> tag or link to it from an external JavaScript file.
  3. Ensure that the script is executed after the page loads to ensure proper functioning.

Example Code

The script should be placed in the <head> or just before the closing </body> tag. Here is a sample of how to include it:

        <script>
        // Insert the JavaScript code here
        </script>
    

Important Notes

  • Not Foolproof: This script can discourage casual users from copying content but can be bypassed by more experienced users using developer tools or by disabling JavaScript.
  • Non-intrusive: The script doesn't affect page performance significantly and doesn't interfere with the normal browsing experience (aside from disabling copy and right-click).
  • Content Protection: While this adds a layer of protection to your content, it is important to remember that no method can completely secure text on the web.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published