How I Wrote a Chrome Extension using ChatGPT

Sonu Singh
2 min readMay 3, 2023

As a software developer, I’m always looking for ways to improve my workflow and productivity. One of the challenges I face when reviewing code is coming up with suggestions for improvement. That’s why I decided to build a Chrome extension that integrates with the ChatGPT API to provide code suggestions.

The extension allows users to enter their ChatGPT API key and save it using Chrome’s storage API. Once the API key is saved, the extension can make requests to the ChatGPT API to generate code suggestions. The extension also injects a content script into web pages to display the code suggestions in a user-friendly way.

When the user selects text on a webpage and right-clicks, a context menu item “Suggest Improvement” is displayed.

The API’s response is displayed in a tooltip next to the selected code snippet, allowing the user to see the suggestions or explanations without leaving the page.

Below is a suggested response for the line -
The API’s response is displayed in a tooltip next to the selected code snippet, allowing the user to see the suggestions or explanations without leaving the page.

Overall, using ChatGPT was a great experience and allowed me to create an extension that can provide helpful code suggestions. The extension is easy to use and can be a valuable tool for developers looking to improve their code review process.

If you’re interested in checking out the code and contributing to the project, the source code is available on GitHub.

GitHub Link - https://github.com/acumino/ChatGPT-Chrome-Extension

--

--