Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

get-private-browsing-name

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-private-browsing-name - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

dist/index.js

128

index.js

@@ -1,127 +0,1 @@

const getPrivateBrowsingName = () => {
const ua = navigator && navigator.userAgent;
const osDict = [
{
os: 'iOS',
regex: /iP(hone|od|ad)/
},
{
os: 'Linux',
regex: /(Linux)|(X11)/
},
{
os: 'Mac OS',
regex: /(Mac_PowerPC)|(Macintosh)/
},
{
os: 'Windows',
regex: /Win/
}
];
const browserDict = [
{
browser: 'edge',
mode: 'InPrivate Browsing',
linkMethod: 'Open link in InPrivate window',
macMethod: 'Command⌘+Shift+p',
windowsMethod: 'Ctrl+Shift+p',
regex: /Edge\/([0-9\._]+)/
},
{
browser: 'edge-ios',
mode: 'InPrivate Browsing',
linkMethod: 'Open link in InPrivate window',
macMethod: 'Command⌘+Shift+p',
windowsMethod: 'Ctrl+Shift+p',
regex: /EdgiOS\/([0-9\._]+)/
},
{
browser: 'firefox',
mode: 'Private Browsing',
linkMethod: 'Open in New Private Window',
macMethod: 'Command⌘+Shift+p',
windowsMethod: 'Ctrl+Shift+p',
regex: /Firefox\/([0-9\.]+)(?:\s|$)/
},
{
browser: 'safari',
mode: 'Private Browsing',
linkMethod: null,
macMethod: 'Command⌘+Shift+n',
windowsMethod: null,
regex: /Version\/([0-9\._]+).*Safari/
},
{
browser: 'chrome',
mode: 'Incognito',
linkMethod: 'Open Link in Incognito Window',
macMethod: 'Command⌘+Shift+n',
windowsMethod: 'Ctrl+Shift+n',
regex: /(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/
},
{
browser: 'ie',
mode: 'InPrivate Browsing',
linkMethod: null,
macMethod: 'Command⌘+Shift+p',
windowsMethod: 'Ctrl+Shift+p',
regex: /Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/
},
{
browser: 'ie',
mode: 'InPrivate Browsing',
linkMethod: null,
macMethod: 'Command⌘+Shift+p',
windowsMethod: 'Ctrl+Shift+p',
regex: /MSIE\s([0-9\.]+);.*Trident\/[4-7].0/
},
{
browser: 'ie',
mode: 'InPrivate Browsing',
linkMethod: null,
macMethod: 'Command⌘+Shift+p',
windowsMethod: 'Ctrl+Shift+p',
regex: /MSIE\s(7\.0)/
}
];
const lookup = (dict, str) => {
for (let i = 0, count = dict.length; i < count; i++) {
const { regex } = dict[i];
const match = regex.exec(str);
if (match) {
return dict[i];
}
}
return null;
}
const getOs = (str) => {
const result = lookup(osDict, str);
return result && result.os || null;
}
const getBrowser = (str) => {
return lookup(browserDict, str);
}
const os = getOs(ua);
const browser = getBrowser(ua);
let detectedMethod = null;
if (os === 'Windows' || os === 'Linux') {
detectedMethod = browser.windowsMethod;
} else if (os === 'Mac OS' || os === 'iOS') {
detectedMethod = browser.macMethod;
}
return browser && {
...browser,
detectedMethod,
} || null;
}
module.exports = getPrivateBrowsingName;
module.exports = require('./dist');
{
"name": "get-private-browsing-name",
"version": "0.1.1",
"version": "0.2.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "jest"
"test": "jest",
"build": "babel src --out-dir dist"
},

@@ -25,5 +26,11 @@ "repository": {

"devDependencies": {
"@babel/cli": "^7.12.10",
"@babel/core": "^7.12.10",
"@babel/preset-env": "^7.12.11",
"jest": "^25.1.0",
"jest-useragent-mock": "^0.0.3"
},
"dependencies": {
"@babel/polyfill": "^7.12.1"
}
}

@@ -5,2 +5,6 @@ ### WIP - Under development

### General rule of thumb:
- **Safari MacOs, iOS:** Private Browsing Mode
- **Gooogle Chrome:** Incognito Mode
```js

@@ -7,0 +11,0 @@ // Example Running in Chrome

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