From 9b1aa31c1634abc28d2330c0b36bda7d61cea939 Mon Sep 17 00:00:00 2001 From: alanfoster Date: Tue, 16 Mar 2021 00:14:01 +0000 Subject: [PATCH] Fix copy paste support --- index.html | 52 ++++++++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/index.html b/index.html index e8344dd..f17458a 100644 --- a/index.html +++ b/index.html @@ -538,6 +538,21 @@ }); } + const uiElements = { + [CommandType.ReverseShell]: { + listSelection: '#reverse-shell-selection', + command: '#reverse-shell-command' + }, + [CommandType.BindShell]: { + listSelection: '#bind-shell-selection', + command: '#bind-shell-command', + }, + [CommandType.MSFVenom]: { + listSelection: '#msfvenom-selection', + command: '#msfvenom-command' + } + }; + const rsg = { selectedValues: { [CommandType.ReverseShell]: filterCommandData(rsgData.reverseShellCommands, { commandType: CommandType.ReverseShell })[0].name, @@ -548,15 +563,15 @@ filter: FilterType.All, copyToClipboard: (text) => { - // if (navigator ?.clipboard ?.writeText) { - // navigator.clipboard.writeText(text) - // $('#clipboard-toast').toast('show') - // } else if (window ?.clipboardData ?.setData) { - // window.clipboardData.setData('Text', text); - // $('#clipboard-toast').toast('show') - // } else { - // $('#clipboard-failure-toast').toast('show') - // } + if (navigator ?.clipboard ?.writeText) { + navigator.clipboard.writeText(text) + $('#clipboard-toast').toast('show') + } else if (window ?.clipboardData ?.setData) { + window.clipboardData.setData('Text', text); + $('#clipboard-toast').toast('show') + } else { + $('#clipboard-failure-toast').toast('show') + } }, escapeHTML: (text) => String(text).replace(//, '>'), @@ -685,13 +700,8 @@ documentFragment.appendChild(selectionButton); }) - const listTargets = { - [CommandType.ReverseShell]: '#reverse-shell-selection', - [CommandType.BindShell]: '#bind-shell-selection', - [CommandType.MSFVenom]: '#msfvenom-selection' - }; - const listTarget = listTargets[rsg.commandType]; - document.querySelector(listTarget).replaceChildren(documentFragment) + const listSelectionElement = uiElements[rsg.commandType].listSelection; + document.querySelector(listSelectionElement).replaceChildren(documentFragment) }, updateListenerCommand: () => { @@ -746,14 +756,8 @@ ) } - const commandTargets = { - [CommandType.ReverseShell]: '#reverse-shell-command', - [CommandType.BindShell]: '#bind-shell-command', - [CommandType.MSFVenom]: '#msfvenom-command' - }; - const commandTarget = commandTargets[rsg.commandType]; - - document.querySelector(commandTarget).innerHTML = command; + const commandElement = uiElements[rsg.commandType].command; + document.querySelector(commandElement).innerHTML = command; }, updateSwitchStates: () => {