(command: ConvertInstructions)
| 7 | const ConvertLists: BaseConverter[] = [new ChatGPTConverter(), new ShareGPTConverter()] |
| 8 | |
| 9 | const tryConvert = (command: ConvertInstructions): ConvertResult => { |
| 10 | try { |
| 11 | for (const converter of ConvertLists) { |
| 12 | if (converter.isActive) { |
| 13 | const content = command === 'CONVERT' ? converter.convert() : converter.currentFileName |
| 14 | return { |
| 15 | success: true, |
| 16 | content, |
| 17 | } |
| 18 | } |
| 19 | } |
| 20 | } catch (e) { |
| 21 | return { |
| 22 | success: false, |
| 23 | error: `${e}`, |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | return { |
| 28 | success: false, |
| 29 | error: 'no convert found', |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | // get popup2content info |
| 34 | chrome.runtime.onMessage.addListener((request: ConvertInstructionRequest, sender, sendResponse) => { |
no test coverage detected