* Handle user action messages from content scripts
(request, sendResponse)
| 165 | * Handle user action messages from content scripts |
| 166 | */ |
| 167 | function handleUserActionMessage(request, sendResponse) { |
| 168 | // Handle user action messages using MESSAGE_HANDLER_MAPPING |
| 169 | |
| 170 | // Look up the handler in the mapping |
| 171 | const handlerInfo = MESSAGE_HANDLER_MAPPING[request.message]; |
| 172 | |
| 173 | if (!handlerInfo) { |
| 174 | console.warn(`No handler found for message: ${request.message}`); |
| 175 | return; |
| 176 | } |
| 177 | |
| 178 | // Call the handler function to generate action data |
| 179 | const actionData = handlerInfo.handler(request); |
| 180 | |
| 181 | // Skip if handler returns null (e.g., filtered keyboard events) |
| 182 | if (actionData === null) { |
| 183 | return; |
| 184 | } |
| 185 | |
| 186 | // Log the action for debugging |
| 187 | console.log(`${handlerInfo.category} action: ${request.message}`, actionData); |
| 188 | |
| 189 | |
| 190 | // Push the action |
| 191 | pushAction(actionData); |
| 192 | } |
| 193 | |
| 194 | // Simple context menu for start/stop recording |
| 195 | chrome.runtime.onInstalled.addListener(function() { |
no test coverage detected