Detect web browsers on macOS from Node.js or Electron via a native module
npm install node-mac-detect-browsers
detect([callback]) (macOS only)
callback
Receives anerror
, if any, and an array ofresults
sorted by thename
property.
Each result
is an object with the following properties:
name
stringpath
string – absolute path to executabledefault
bool (optional) – indicates the default application
Note: an error occurs if no browsers were found.
In main process:
const { detect } = require("node-mac-detect-browsers");
detect((err, results) => {
if (err) {
console.error(err);
}
console.log(results);
});
or async:
(async () => {
try {
const browsers = await detect();
console.log(browsers);
} catch (err) {
console.error(err);
}
})();
Example output:
[
{
"name": "Arc",
"path": "/Applications/Arc.app"
},
{
"name": "Brave Browser",
"path": "/Applications/Brave Browser.app"
},
{
"name": "Chromium",
"path": "/Applications/Chromium.app"
},
{
"name": "Firefox",
"path": "/Applications/Firefox.app"
},
{
"name": "Google Chrome",
"path": "/Applications/Google Chrome.app"
},
{
"default": true,
"name": "Safari",
"path": "/System/Volumes/Preboot/Cryptexes/App/System/Applications/Safari.app"
},
{
"name": "Tor Browser",
"path": "/Applications/Tor Browser.app"
}
]
MIT License
- RSWeb, part of NetNewsWire