-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from PRO100BYTE/add-aboutme-command
Add aboutme command
- Loading branch information
Showing
2 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
export default class AboutmeCommand { | ||
execute(term, params, directory, setDirectory) { | ||
let userAgent = navigator.userAgent; | ||
let browserMatch = userAgent.match(/(Firefox|Edg|Edge|Chrome|Safari|Opera|MSIE|Trident)\/?\s*(\d+)/i); | ||
let browserName = browserMatch[1]; | ||
let browserVersion = browserMatch[2]; | ||
let osMatch = userAgent.match(/(iOS|iPhone OS|Android|Symbian|Windows|Mac OS X|Linux)/i); | ||
let osName = osMatch[1]; | ||
let hostname = window.location.hostname; | ||
term.writeln("User agent: " + userAgent); | ||
term.writeln("Browser name: " + browserName); | ||
term.writeln("Browser version: " + browserVersion); | ||
term.writeln("Operating system: " + osName); | ||
term.writeln("Hostname: " + hostname); | ||
} | ||
|
||
description() { | ||
return "Prints information about the user's browser and device"; | ||
} | ||
|
||
help(term) { | ||
term.writeln("Usage: aboutme"); | ||
term.writeln("Prints information about the user's browser and device, such as user agent, browser name and version, operating system, and hostname."); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters