How to Create Chrome Extension in Just 1 Minute!

1K Blog Marathon: Day 42

Do you want to change the background color of your favorite website?

Have you been wondering what a Chrome Extension is?

Chrome extensions (a.k.a. Chrome plugin) is a piece of software installed on your Chrome browser. This extensions aims to customize your browsing experience and even performs complex functionalities.

Basically, if you want to change the behavior or a website, or process certain things on it like copying all links, counting all words and even extracting keywords, but you can’t because the website doesn’t offer that feature, you can do it yourself using Chrome Extensions.

Chrome extensions are found on the top-right corner of the browser. Some can independently function like timer, while others are working only when you are in a particular website, like ProcFu for Podio website.

If you’re a newbie programmer who wants to perform different tasks in your Chrome browser, or a seasoned professional who wants to know how to create your own Chrome extension, this tutorial is best for you.

Few Technicalities

This tutorial’s prerequisite is basic HTML knowledge.

Basically, a Chrome Extension is composed of a Manifest file, HTML file, and a Javascript file. Optional files, like CSS can be used. Note that PHP files cannot be included as extensions run on the browser and not on a server. If you want to use PHP file, you need to put it on your server and call it via Javascript.

Chrome Extensions has 2 Actions

  1. Page Action – specific for a certain page, like Netflix Party that will work only on Netflix website.
  2. Browser Action – can function on all pages, example is Fonts Ninja that can identify fonts on any websites.

Types of Scripts

  1. Background Scripts
    • Invisible page that works on background, like setting a timer.
  2. Content Scripts
    • Can access the webpage which the user is interacting, ex. Change the site’s font style, background image, etc.

Let’s get our hands dirty!

In this tutorial, we will be creating a simple Chrome Extension that will show a small popup window when clicked.

We will only need 3 files:

  1. manifest.json – Manifest file in json format.
  2. popup.html – Simple website for interface.
  3. tab-icon.png – an image for logo.

Step 1

First, create a Manifest file. Open your text/code editor, create “manifest.json”, and paste the following codes:

{
	"name":"Curbside Notes",

	"author":"Xtian",

	"version":"1",

	"manifest_version": 2,

	"description":"Notepad? Sticky Notes? NO MORE!.",

	"icons":{
		"16":"tab-icon.png"
	},
	
	"browser_action": 
	{		 
		"default_popup": "popup.html"
	} 
 
}

Explanations:

  1. name – required, serves as the name of your project.
  2. author – optional, name of the author.
  3. version – required, version/revision number. It is advisable to use multiple number for versioning, like 0.0.1, if you have many revisions.
  4. manifest_version – required, the version of your manifest.
  5. description – optional, few texts to describe your extension.
  6. icons – required, this is the icon of your extension that will be shown in your browser once installed.
  7. browser_action: default_popup – required, tells the browser to show “popup.html” when the icon was clicked.

Step 2

Now create another file, name it “popup.html”, and save it on the same folder as the manifest. Paste this code.

<!DOCTYPE html>
<html lang="en">

<head>
    <title>Curbside Notes</title>
</head>

<style>
    body {
        height: 100px;
        width: 100px;
        padding: 20px;
        border: 1px solid #f4f4f4;
        background-color: azure;
    }
</style>

<body>

    HELLO WORLD!
    <br>
    <br>
    This is a simple Chrome Extension!

    <br>
    <br>
    Powered by Curbside Coder

</body>

</html>

Explanation:

This is just a simple html file, with on-page styling to make it more appealing, and few messages.

Step 3, the final and hardest step.

Last is download this image, rename it as “tab-icon.png

tab-icon.png

Installation

There are two ways to install Chrome extensions. One is by downloading it from Chrome Store. This only works on Published Extension. Second is by uploading it locally from your computer to your browser. This is not published and only you can access it.

I will teach you how to install it locally.

1. Open your Chrome browser and navigate to chrome://extensions/. Optionally, you can click the Settings (vertical ellipsis on the top right corner of your browser) >> More Tools >> Extensions.

2. Enable “Developer mode”. You can see a switch toggle on the top right corner.

3. Click “Load unpacked”.

4. A popup window will appear. Browse your folder and select it.

5. Now you will be able to see it listed. Also it will appear on the extensions on the upper right corner of the browser, along with the other extensions you’ve installed.

6. If you didn’t see it on the extensions bar, click the puzzle icon, and “pin” the extension by clicking the pin icon next to it.

7. Now you have successfully created and installed your first Chrome Extension!

If you notice, Chrome Extension’s interface runs in HTML, which may make you think that you can create a web app and make it an extension! Technically you’re right, but as I’ve said earlier, you cannot use PHP. Come again for more elaborate Chrome Extension Project that I will post! Thank you and happy coding!

“And that’s one blog, stay hungry!”

“Extension of God’s glory brings about expansion”

Sunday Adelaja

Published by Christian Foster

Code-blooded, coffee-lover, tall, dark and chubby. I love to draw, has motion-sickness and a sleepy-head. BTW, graduate of BS Computer Science, Associate in Computer Science and certified UiPath RPA Developer. Loyal to my partner and a father of a cute bouncing baby daughter!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create your website at WordPress.com
Get started
%d bloggers like this: