![]() "background" sets the script to be run in the background. Based on the requested permissions, Chrome may display a warning as explained here. Permissions are requested by the extension when installing. It can be requesting API access as in our case, or also a match pattern. "permissions" lists permissions needed by the extension. In our case, we will use this page to set a list of websites to block, and also to easily enable/disable the blocking. "options_page" is a page to open when you right-click the extension in the toolbar, and select Options from the menu. Any other fields besides "manifest_version", "name" and "version", are optional and we add them as needed. The structure of this file is explained here. Let's now create the extension Block Site.Įnter fullscreen mode Exit fullscreen mode "tabs" API will be needed to get the tab url we are trying to open, and based on whether the domain is on the blocked list or not, we close the tab instantly, or let it proceed. "storage" API will be needed to store the websites user wants to block the access to, to boost his productivity, and it will also be used to store an option to quickly disable or enable the blocking at any given moment. To open Options, generally you right-click on the extension icon in the toolbar and choose Options from the menu. Options refers to "options_page" which the extension can have. ![]() Block Site is by default disabled and doesn't block any website until you say so in Options. Block Site, which we are about to create to learn and practice the two APIs, is available hereīlock Site is a simple Chrome extension that improves your productivity by blocking the access to time-consuming websites (like during the working hours) as you specify in Options.the full list of APIs available to Chrome extensions is here.the APIs you will learn in this tutorial are called "storage" and "tabs".This article will explain you how to use the most useful Chrome APIs by creating a simple Chrome extension called Block Site.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |