biased-opener
Cross-platform, opens a URL with one of the browsers passed as parameter (if available in the system), preferably default browser of the user
Last updated 10 years ago by jakub-g .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install biased-opener 
SYNC missed versions from official npm registry.

biased-opener

Build Status

Get it on npm

This module tries to open the provided URL in some of the user-supplied browsers available on the machine. It prefers the default browser of the user, otherwise it tries all other browsers in the order in which they were passed.

If no conforming browsers found, it doesn't launch anything, just calls the callback with an error.

Tested on Windows 7 64-bit, Windows XP 32-bit, Ubuntu 14.04 64-bit, Mac OS X 10.10 (en-US locale).

It requires nodejs and npm. If you don't have node, grab it at nodejs.org. Node installer bundles npm (node package manager)

Rationale

Certain applications require certain webkit-only features (for instance, Node Inspector). For that apps, it makes sense to only open a URL in a webkit browser, otherwise tell the user about the error instead of opening the URL in unsupported browser.

Usage as a nodejs module

$ npm install biased-opener
var biasedOpener = require('biased-opener');

var url = "http://example.org";
var cfg = {
  verbose: true,
  preferredBrowsers: ['chrome', 'opera'] // comma-delimited string "chrome, opera" is also accepted
};
// if `cfg` is not passed, it defaults to `{ verbose: false, preferredBrowsers: ['chrome'] }`

biasedOpener(url, cfg, function(err, okMsg, instance) {
    if (err) {
        // didn't find any matching browser, or there was some failure while launching it
    }
    if (instance) {
        // control the instance if you need it
        // see https://github.com/benderjs/browser-launcher2#instance
    }
});

Usage from command line

$ npm install -g biased-opener
$ biased-opener -h                             # to see all the options
$ biased-opener --verbose --browsers 'chrome, opera' 'http://example.org'

If --browsers is not passed, it defaults to chrome.

Recognized browsers

  • chrome
  • chromium
  • opera
  • firefox
  • safari
  • ie

Linux support

This module was only tested on Ubuntu. Compatibility reports and fixes for other distros are more than welcome! Use GitHub issues or email: (jakub.g.opensource) (gmail)

License

MIT © Jakub Gieryluk

Related projects

  • browser-launcher2 (cross-platform)
  •          [opener](https://github.com/domenic/opener) (cross-platform)
    

Current Tags

  • 0.2.8                                ...           latest (9 years ago)

9 Versions

  • 0.2.8                                ...           9 years ago
  • 0.2.7                                ...           9 years ago
  • 0.2.6                                ...           9 years ago
  • 0.2.5                                ...           10 years ago
  • 0.2.4                                ...           10 years ago
  • 0.2.3                                ...           10 years ago
  • 0.2.2                                ...           10 years ago
  • 0.2.1                                ...           10 years ago
  • 0.2.0                                ...           10 years ago
Maintainers (1)
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (4)
Dev Dependencies (1)
Dependents (0)
None

© 2010 - cnpmjs.org x YWFE | Home | YWFE