Company
Date Published
Author
Phil Nash
Word count
924
Language
English
Hacker News points
None

Summary

In a Chrome browser, a new feature was added to capture screen output using an installed extension. However, there was a missing functionality: detecting whether the extension is installed before attempting to use it. A new Chrome extension was built to address this issue, allowing developers to detect its presence from the front end. The extension uses the `chrome.runtime.onMessageExternal` event listener to listen for messages sent by web pages to the extension. If the message is "version", the extension responds with its current version number. To test this functionality, a Chrome screen capture example was updated to send the "version" message to the extension and detect its presence based on the response. When the extension is installed and enabled, the "Get the screen" button appears in the page, allowing users to interact with it. If the extension is disabled or not installed, the button does not appear, and a "No extension" message is logged to the console.