anti-scrape-shield
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

Anti-Scrape Shield

Anti-Scrape Shield is a lightweight library designed to protect your web applications from scraping attempts. It works with React, Vue, Angular, Svelt,Next and Remix applications.

Installation

npm install anti-scrape-shield

Usage

import AntiScrapeShield from 'anti-scrape-shield';

const shield = new AntiScrapeShield({
  obfuscate: true,
  honeypot: true,
  detect: true,
  rateLimit: {
    maxRequests: 100,
    perSeconds: 60
  }
});

// In a React component
useEffect(() => {
  const rootElement = document.getElementById('root');
    if (rootElement) {
      shield.protect(rootElement);
    }
}, []);

// In a Vue component
mounted() {
  shield.protect(this.$el);
}

// In an Angular component
ngAfterViewInit() {
  shield.protect(this.elementRef.nativeElement);
}


// In a Svelte component
<script>
  import { onMount } from 'svelte';
  import AntiScrapeShield from 'anti-scrape-shield';

  let componentElement;

  onMount(() => {
    const shield = new AntiScrapeShield({
      obfuscate: true,
      honeypot: true,
      detect: true,
      rateLimit: {
        maxRequests: 100,
        perSeconds: 60
      }
    });
    shield.protect(componentElement);
  });
</script>

<div bind:this={componentElement}>
  Protected content
</div>


// In a Next.js component (Client-side only)
import { useEffect, useRef } from 'react';

function MyComponent() {
  const componentRef = useRef(null);

  useEffect(() => {
    if (typeof window !== 'undefined' && componentRef.current) {
      const shield = new AntiScrapeShield({
        obfuscate: true,
        honeypot: true,
        detect: true,
        rateLimit: {
          maxRequests: 100,
          perSeconds: 60
        }
      });
      shield.protect(componentRef.current);
    }
  }, []);

  return <div ref={componentRef}>Protected content</div>;
}

// In a Remix component (Client-side only)
import { useEffect, useRef } from 'react';
import { ClientOnly } from 'remix-utils';

function MyComponent() {
  const componentRef = useRef(null);

  useEffect(() => {
    if (componentRef.current) {
      const shield = new AntiScrapeShield({
        obfuscate: true,
        honeypot: true,
        detect: true,
        rateLimit: {
          maxRequests: 100,
          perSeconds: 60
        }
      });
      shield.protect(componentRef.current);
    }
  }, []);

  return (
    <ClientOnly>
      {() => <div ref={componentRef}>Protected content</div>}
    </ClientOnly>
  );
}

💻 Built with

Technologies used in the project:

  • Typescript

Features

  • Content obfuscation
  • Honeypot traps
  • Suspicious behavior detection
  • Rate limiting

💻 Technologies used in the project:

Static Badge

Static Badge

🛡️ License:

MIT

Package Sidebar

Install

npm i anti-scrape-shield

Version

1.0.2

License

MIT

Unpacked Size

9.79 kB

Total Files

14

Last publish

Collaborators

  • achref_hasni