Skip to content

Commit

Permalink
Merge pull request #45 from PRO100BYTE/add-aboutme-command
Browse files Browse the repository at this point in the history
Add aboutme command
  • Loading branch information
mraliscoder authored Jul 30, 2023
2 parents 7478111 + f695888 commit 21c7a93
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/commands/Utility/aboutme.js
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.");
}
}

2 changes: 2 additions & 0 deletions src/registration.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import DeleteCommand from "./commands/Filesystem/rm";
import DeleteDirectoryCommand from "./commands/Filesystem/rmdir";
import WeatherCommand from "./commands/Utility/weather";
import StatusCommand from "./commands/System/status";
import AboutmeCommand from "./commands/Utility/aboutme";
import DownloadCommand from "./commands/Filesystem/download";
import UploadCommand from "./commands/Filesystem/upload";

Expand Down Expand Up @@ -63,6 +64,7 @@ export const registerAllCommands = () => {
registeredCommands['ip'] = new IpCommand();
registeredCommands['geoip'] = new GeoIpCommand();
registeredCommands['geo'] = new GeoCommand();
registeredCommands['aboutme'] = new AboutmeCommand();
registeredCommands['weather'] = new WeatherCommand();

// ECodeAPI
Expand Down

0 comments on commit 21c7a93

Please sign in to comment.