function getColorFromElementByPath(path) { const element = document.querySelector(path); if (!element) { throw new Error('Element not found for the provided path'); } const style = window.getComputedStyle(element); const backgroundColor = style.backgroundColor; const rgbMatch = backgroundColor.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/); if (!rgbMatch) { throw new Error('Unable to parse RGB values from the element'); } const red = parseInt(rgbMatch[1], 10); const green = parseInt(rgbMatch[2], 10); const blue = parseInt(rgbMatch[3], 10); if (red > green && red > blue) { return 'red'; } else if (green > red && green > blue) { return 'green'; } else if (blue > red && blue > green) { return 'blue'; } else { return 'unknown color'; } } catch (error) { return `Error: ${error.message}`; } } return result;