New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ajax-hacker

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ajax-hacker

hack your ajax

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

ajax-hacker

Hack your ajax

Ajax-hacker supply a function that can hack ajax object(XMLHttpRequest, ActiveXObject and XDomainRequest), modify it and add hooks on it. Others who use ajax object will not even notice it.

Actually I use it in a front-end performance monitoring project.

Installation

npm install ajax-hacker --save

Useage

You can import ajax-hacker in both AMD and CommonJS way

var ajaxHacker = require('ajax-hacker')

Or you can just link ajax-hacker with a script tag, In this way, an Object called ajaxHacker have been insert into global object.

<script src="./ajax-hacker.js"></script>

And you can use it like this below:

ajaxHacker({
  responseType: 'json',
  timeout: 3000,
  withCredentials: false,
  onabord: function (e, next) {
    console.log('hacker onabord: ', e, this)
    next()
  },
  onerror: function (e, next) {
    console.log('hacker onerror: ', e, this)
    next()
  },
  onload: function (e, next) {
    console.log('hacker onload: ', e, this)
    next()
  },
  onloadend: function (e, next) {
    console.log('hacker onloadend: ', e, this)
    next()
  },
  onloadstart: function (e, next) {
    console.log('hacker onloadstart: ', e, this)
    next()
  },
  onprogress: function (e, next) {
    console.log('hacker progress ', e, this)
    next()
  },
  ontimeout: function (e, next) {
    console.log('hacker timeout ', e, this)
    next()
  },
  upload: {
    // except onreadystatechange, beforeOpen, beforeSend and beforeAbord, upload object support the same hooks as xhr object
    onprogress: function (e, next) {
      console.log('hacker upload onprogress', e)
      next()
    }
    // ...etc
  },
  onreadystatechange: function (e) {
    console.log('hacker readystatechange', e, this)
  },
  beforeOpen: function (next, method, url, async, user, password) {
    console.log('beforeOpen ', method, url)
    next()
  },
  beforeSend: function (next, body) {
    console.log('beforeSend ', body)
    next()
  },
  beforeAbord: function (next) {
    console.log('beforeAbord')
    next()
  }
}

Now your ajax object will follow your step like a lovely dog.

Keywords

FAQs

Package last updated on 22 Jan 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc