xpi
Library for unpacking Firefox addons and extract their script contents.
Last updated 5 years ago by dherman .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install xpi 
SYNC missed versions from official npm registry.

xpi.js

Unpack Firefox addon XPI files and extract their JavaScript source code.

Usage

var XPI = require('xpi');

(new XPI.SourceEmitter("./adblock_plus-2.6.7-sm+tb+fx+an.xpi"))
  .on("script", function(script) {
    // extracted a script file (.js or .jsm) from the XPI
  })
  .on("overlay", function(overlay) {
    // extracted a XUL overlay file (.xul) from the XPI
  })
  .on("end", function() {
    // done extracting
  })
  .on("error", function(err) {
    // error occurred
  });

(new XPI.JSEmitter("./adblock_plus-2.6.7-sm+tb+fx+an.xpi"))
  .on("javascript", function(js) {
    // extracted a JS source file or snippet from the XPI
    switch (js.type) {
      case 'file':
        // JS source file
      case 'script':
        // <script> tag from a XUL file
      case 'attribute':
        // inline attribute script from a XUL file
    }
  })
  .on("end", function() {
    // done extracting
  })
  .on("error", function(err) {
    // error occurred
  });

Class: new XPI.SourceEmitter(path)

Event: 'script'

  • fileName: String
  • source: String

Event: 'overlay'

  • fileName: String
  • source: String

Class: new XPI.JSEmitter(path)

Event: 'javascript'

js.type === 'file'

  • fileName: String
  • source: String

js.type === 'script'

  • fileName: String
  • source: String
  • line: Number

js.type === 'attribute'

  • fileName: String
  • source: String
  • line: Number
  • tag: String
  • eventType: String

License

Copyright © 2015 Dave Herman

Licensed under the MIT License.

Current Tags

  • 0.2.4                                ...           latest (5 years ago)

13 Versions

  • 0.2.4                                ...           5 years ago
  • 0.2.3                                ...           5 years ago
  • 0.2.2                                ...           5 years ago
  • 0.2.1                                ...           5 years ago
  • 0.1.4                                ...           8 years ago
  • 0.1.3                                ...           8 years ago
  • 0.1.2                                ...           8 years ago
  • 0.1.1                                ...           8 years ago
  • 0.0.5                                ...           8 years ago
  • 0.0.4                                ...           8 years ago
  • 0.0.3                                ...           8 years ago
  • 0.0.2                                ...           8 years ago
  • 0.0.1                                ...           8 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 13
Last Day 0
Last Week 0
Last Month 0
Dependencies (4)
Dev Dependencies (0)
None
Dependents (2)

Copyright 2014 - 2016 © taobao.org |