Creating a Chrome Extension
First steps to develop extensions for Google Chrome, with local data storage and direct interaction with the DOM
What is a Chrome extension?
According to documentations, it is a small software program designed to run on the Google Chrome web browser. These extensions are designed to add extra functionality to the browser, personalize the user experience, and improve productivity.
Extensions can be downloaded and installed from the Chrome Web Store, which is Chrome’s app store.
What do we intend to do?
To understand a little about extensions, we will make a simple autofill application. Basically the plugin must save data in its own local storage and it must be possible to input the data directly into the DOM.
Only HTML, CSS, and JavaScript languages will be used for development, it seems simple, right?
Creating the Extension?
To carry out this tutorial you will need to have a text editor installed on your machine.
After installation, we will start development. The Chrome API has a service that needs a configuration file called manifest.json, with all the information needed to initialize the extension, for example:
Now it will be necessary to create a messaging file called background.js, which will be our main service for the conversation between the extension data.
Finally, it is necessary to create a service called content.js, which will be our DOM manipulation service.
Now data saved in Chrome storage, which allows extensions and web applications to store data on the user’s device, such as settings, preference information and other relevant information, is input directly to the target page.
Now to call the extension directly from an Angular application, you just need to send the postMessage function.
Deployment
Okay, our extension is finished! Now just add it manually to your browser in the Manage Extensions tab of Google Chrome.
Thanks for reading
Hope you found my blog fun. If you have any questions, you can check my blog’s repo on Github or feel free to reach out to me on LinkedIn.