# screenshot-prevention

> Screenshot prevention library

Latest version **1.0.1** (published 2024-11-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install screenshot-prevention
pnpm add screenshot-prevention
yarn add screenshot-prevention
bun add screenshot-prevention
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2024-11-25 |
| First published | 2024-11-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 175.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Mohammed Ismail |
| Maintainers | md.13ismail |
| Keywords | screenshot, prevention, security, screen-capture |

## Links

- npm: https://www.npmjs.com/package/screenshot-prevention
- npm.io page: https://npm.io/package/screenshot-prevention

## Alternatives

- [async-exit-hook](https://npm.io/package/async-exit-hook.md) — 3.7M weekly downloads
- [evnty](https://npm.io/package/evnty.md) — 7.2K weekly downloads
- [eleventy-plugin-asciidoc](https://npm.io/package/eleventy-plugin-asciidoc.md) — 3.5K weekly downloads
- [@jswork/next-get2get](https://npm.io/package/@jswork/next-get2get.md) — 945 weekly downloads
- [@dashersw/axon](https://npm.io/package/@dashersw/axon.md) — 934 weekly downloads

## Recent versions

- 1.0.1 (latest) — 2024-11-25

## README

# Screenshot Prevention Library

A high-performance JavaScript library to prevent screenshots, screen recordings, and screen sharing on web applications.

## Features

- 🚫 Block screenshots and screen recordings
- 🖼️ Prevent screen sharing
- 📱 Mobile device support
- ⚡ High-performance implementation
- 🎨 Customizable UI and messaging
- 🔄 Automatic recovery
- 📦 Zero dependencies
- 💻 TypeScript support

## Installation

### NPM
```bash
npm install screenshot-prevention
```

### CDN
```html
<script src="https://cdn.jsdelivr.net/npm/screenshot-prevention@latest/dist/screenshot-prevention.min.js"></script>
```

## Quick Start

### Basic Usage
```html
<!-- Auto-initialize with default settings -->
<script src="screenshot-prevention.min.js" data-auto-init></script>
```

### Manual Initialization
```javascript
const prevention = new ScreenshotPrevention({
  blurIntensity: '20px',
  warningMessage: 'Screenshots are not allowed on this website.',
  preventCopy: true,
  preventInspect: true,
  recoveryDelay: 2000,
  onAttempt: (details) => {
    console.log('Screenshot attempted:', details);
  }
});
```

## Configuration Options

| Option | Type | Default | Description |
|--------|------|---------|-------------|
| blurIntensity | string | '20px' | Blur intensity when prevention is triggered |
| warningMessage | string | 'Screenshot and screen recording are not allowed.' | Custom warning message |
| preventCopy | boolean | true | Prevent content copying |
| preventInspect | boolean | true | Prevent inspect element |
| recoveryDelay | number | 2000 | Recovery delay in milliseconds |
| debug | boolean | false | Enable debug logging |
| onAttempt | function | null | Callback for screenshot attempts |

## API Reference

### Methods

- `getAttemptCount()`: Get the number of screenshot attempts
- `reset()`: Reset the prevention state
- `destroy()`: Clean up and remove event listeners

### Events

The `onAttempt` callback receives an object with:
- `count`: Number of attempts
- `method`: Detection method used
- `timestamp`: Timestamp of the attempt

## Browser Support

- Chrome 76+
- Firefox 69+
- Safari 13+
- Edge 79+
- iOS Safari 13.4+
- Chrome for Android 76+

## Contributing

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

## Publishing Instructions

1. Create a new repository on GitHub
2. Initialize your local project:
   ```bash
   npm init
   git init
   ```

3. Set up your project structure:
   ```
   screenshot-prevention/
   ├── src/
   │   └── index.js
   ├── dist/
   │   ├── screenshot-prevention.js
   │   └── screenshot-prevention.min.js
   ├── examples/
   │   └── index.html
   ├── package.json
   ├── README.md
   ├── LICENSE
   └── .gitignore
   ```

4. Add build scripts to package.json:
   ```json
   {
     "scripts": {
       "build": "rollup -c",
       "test": "jest",
       "prepare": "npm run build"
     }
   }
   ```

5. Create and push to GitHub:
   ```bash
   git add .
   git commit -m "Initial commit"
   git remote add origin https://github.com/username/screenshot-prevention.git
   git push -u origin main
   ```

6. Publish to npm:
   ```bash
   npm login
   npm publish
   ```

7. Set up GitHub Actions for automated testing and publishing:
   ```yaml
   name: CI/CD
   on: [push, pull_request]
   jobs:
     build:
       runs-on: ubuntu-latest
       steps:
         - uses: actions/checkout@v2
         - uses: actions/setup-node@v2
         - run: npm ci
         - run: npm test
         - run: npm run build
   ```

## License

MIT License - free for commercial and personal use.

## Support

- GitHub Issues: [Report a bug](https://github.com/Mohd-ismail0/screenshot-prevention/issues)
- Email: md.13ismail@gmail.com

---
_Source: https://npm.io/package/screenshot-prevention · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
