From a9af085c7c3c78a57e931ac2bac27253f4e1810c Mon Sep 17 00:00:00 2001 From: #TheDayG0ne Date: Mon, 31 Jul 2023 01:29:00 +0700 Subject: [PATCH] Add aboutme command --- src/commands/Utility/aboutme.js | 26 ++++++++++++++++++++++++++ src/registration.js | 2 ++ 2 files changed, 28 insertions(+) create mode 100644 src/commands/Utility/aboutme.js diff --git a/src/commands/Utility/aboutme.js b/src/commands/Utility/aboutme.js new file mode 100644 index 0000000..a568d11 --- /dev/null +++ b/src/commands/Utility/aboutme.js @@ -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."); + } + } + \ No newline at end of file diff --git a/src/registration.js b/src/registration.js index 230973a..1d2aec6 100644 --- a/src/registration.js +++ b/src/registration.js @@ -23,6 +23,7 @@ import CommandCOMCommand from "./commands/System/command"; import DeleteCommand from "./commands/Filesystem/rm"; import DeleteDirectoryCommand from "./commands/Filesystem/rmdir"; import StatusCommand from "./commands/System/status"; +import AboutmeCommand from "./commands/Utility/aboutme"; export const registerAllCommands = () => { let registeredCommands = {}; @@ -58,6 +59,7 @@ export const registerAllCommands = () => { registeredCommands['ip'] = new IpCommand(); registeredCommands['geoip'] = new GeoIpCommand(); registeredCommands['geo'] = new GeoCommand(); + registeredCommands['aboutme'] = new AboutmeCommand(); // ECodeAPI registeredCommands['ecode'] = new ECodeAPICommand();