What is the Chrome plugin

The Chrome plugin offers the same experience as a native app, but with the same security as a web page. Just like web apps, Chrome plugins are written using HTML5, JavaScript, and CSS, but Chrome plugins look and act like native apps, and they have native-like capabilities that are more powerful than those available on the web.

Chrome plugins always load their pages locally, which makes applications less dependent on the web. Once users install the plug-in, they have complete control over the application’s life cycle. Applications can be opened and closed quickly, and plug-ins can be closed at any time to improve performance. Users can uninstall the plug-in completely.

How to develop chrome plugins

Chrome plugin projects and ordinary web pages, the same need HTML, CSS, javascript files. This means you can use regular development tools. The difference is that the root directory requires a manifest.json file. This is a description file that tells Chrome some basic information.

Create the manifest. Json

Manifest.json: manifest.jsonDevelopers.chrome.com/extensions/…

Additional configurations in Webpack:

1. Change the file name of the package result2. Use copy-webpack-plugin

ContentScripts file

Plug-ins cannot directly manipulate web content, but can inject JS files into the page for information interaction. Use the Runtime. SendMessage, tabs. SendMessage apis. ContentScripts is the JS file that we inject into the web page with an event listener that receives instructions from the plug-in and responds accordingly. It will be injected in the appropriate lifecycle of our configuration, currently in the document_start phase.

Content to interact with contentScript:

Commonly used chrome API: developers.chrome.com/extensions/…

Installing a plug-in