npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

anti-robot

v1.1.0

Published

A robot-like behaviour detection tool.

Downloads

11

Readme

anti-robot

A robot-like behaviour detection tool.

Getting Started

Installing

Copy /build/anti-robot.min.js

Or, install via npm:

npm install anti-robot

Importing

<script type="text/javascript" src="./anti-robot.min.js"></script>
<script>
    AntiRobot.detectRobot(function(code, info) {
      // some code to handle it
    });
</script>

Or, if you installed via npm:

import * as AntiRobot from 'anti-robot';

AntiRobot.detectRobot((code, info) => {
  // some code to handle it
});

Documentation

detectRobot()

Turn on robot-like behaviour detection.

Syntax:

AntiRobot.detectRobot(handler [, signOpts, threshold]);

Parameters:

handler - Callback function which receive a notification (the code and the object with event target) when a robot-like behaviour is detected. See The robot handler for details on the callback itself.

signOpts [optional] - An options object helps to generate the signature. Signature is to identify the page is reloaded / redirected or not.

threshold [optional] - The time interval of the last five click events, also the time interval between the last mouse move event and the last click event during the robot-like behaviour evaluation. Default is 10000ms. The unit is millisecond.

checkSignature()

Check current signature is the same as the original or not.

Syntax:

AntiRobot.checkSignature([signOpts]);

Parameters:

signOpts [optional] - An options object helps to generate the signature. Signature is to identify the page is reloaded / redirected or not.

Return:

result - boolean, true is the same, otherwise false.

reset()

reset the signature, handler and threshold.

Syntax:

AntiRobot.reset();

Usage notes

The robot handler

Syntax:

function robotHandler(code, info) {
  switch (code) {
    case 1: {
      // handle robot UA
      break;
    }
    case 2: {
      // handle click without mouse movement 
      break;
    }
    case 3: {
      // handle fake click
      break;
    }
  }
}

Parameters:

code - The code presents the rule of the robot-like behaviour evaluation.

1 - user agent contains suspect robot keyword.

2 - triggers click event without mouse movement in the latest short period.

3 - triggers click event without local coordinates of the mouse pointer.

info - An object based on click event description

Compatibility

Desktop

  • Edge 50 and above
  • Firefox 50 and above
  • Chrome 45 and above
  • Safari 12 and above
  • Opera 50 and above

NOT supports IE !!!

Mobile Device

TODO