DEV Community

Cover image for Creating Firefox browser extensions -9

Creating Firefox browser extensions -9

Fullstack JS dev, Upcoming Author "Gatsby Cookbook"
Originally published at ・5 min read

Alt Text

Welcome to part-9 of the series. We will continue building extensions, which show some type of image when we open a new tab.

The second tab extension will be called Developer Tab. So, go ahead and create a folder DeveloperTab and inside it another folder icons. Inside that folder place two icons. You can get them from the github link at the end of this post.


Now, create a file manifest.json inside the folder DeveloperTab and put the below content in it. It is quite similar to the file in previous extension and contains the parameter chrome_url_overides.


Now, this extension contains a cool trick with images. I had learned it from the awesome free course JavaScript 30 from Wes Bos. The link for the course is and i made it with, the marked tutorial.

JavaScript 30JavaScript 30

So, not much explanation here. Please follow the above tutorial for the working. Go ahead and put the below in a file tabs.html in the same folder.

Here, we have three different set of texts, which we are going to choose randomly and display within images.

    <!DOCTYPE html>
    <html lang="en">
      <meta charset="UTF-8">
      <link rel="stylesheet" href="tabs.css"/>
      <title>Developer Tab 💻</title>
      <link href='['](') rel='stylesheet' type='text/css'>

      <div id="panels1" style="display:none;">
        <div class="panel panel1">
        <div class="panel panel2">
        <div class="panel panel3">
        <div class="panel panel4">

    <div id="panels2" style="display:none;">
        <div class="panel panel1">
        <div class="panel panel2">
        <div class="panel panel3">
        <div class="panel panel4">

    <div id="panels3" style="display:none;">
        <div class="panel panel1">
        <div class="panel panel2">
        <div class="panel panel3">
        <div class="panel panel4">

    <script src="tabs.js"></script>


Next, let’s create the style file. Place a file tabs.css in the same folder and the below content in it.

We are taking four developer random images from, as background for panel1, panel2, panel3 and panel4.

    html {
        box-sizing: border-box;
        font-family:'helvetica neue';
        font-size: 20px;
        font-weight: 200;
    body {
        margin: 0;
      *, *:before, *:after {
        box-sizing: inherit;
    .panel {
        box-shadow:inset 0 0 0 5px rgba(255,255,255,0.1);
        text-align: center;
            font-size 0.7s cubic-bezier(0.61,-0.19, 0.7,-0.11),
            flex 0.7s cubic-bezier(0.61,-0.19, 0.7,-0.11),
            background 0.2s;
        font-size: 20px;
        flex: 1;
        justify-content: center;
        display: flex;
        flex-direction: column;

    .panel1 { background-image:url([](; }
    .panel2 { background-image:url([](; }
    .panel3 { background-image:url([](; }
    .panel4 { background-image:url([](; }

    /* Flex Items */
      .panel > * {
        width: 100%;
        transition:transform 0.5s;
        flex: 1 0 auto;
        justify-content: center;
        align-items: center;

    .panel > *:first-child { transform: translateY(-100%); } > *:first-child { transform: translateY(0); }
      .panel > *:last-child { transform: translateY(100%); } > *:last-child { transform: translateY(0); }

    .panel p {
        text-transform: uppercase;
        font-family: 'Amatic SC', cursive;
        text-shadow:0 0 4px rgba(0, 0, 0, 0.72), 0 0 14px rgba(0, 0, 0, 0.45);
        font-size: 2em;
    .panel p:nth-child(2) {
        font-size: 4em;
    } {
        flex: 5;

Now, if we load the extension in firefox and then open a new tab, we can see a big blank page with yellow background. All the panels are display: none in html, so nothing is shown.

You can learn how to open an extension for testing in my previous post here.

Yellow backgroundYellow background

Let’s add to logic to show the images and also the click animation. Create a new file tabs.js in the same directory.

Now, in this file the anonymous function runs on page load and the Math.random, chooses any one of the three panels. After that we show them by flex.


The below is what we get from the code.


Now, when we click on any of the tab, it calls the functions toggleOpen() and toggleActive(), which sets the properties in CSS and open the complete text.


We can click on all of the tabs and it will distribute the space between them.

Code longCode long

So, it’s time to publish it in the mozilla addon store. I will follow the procedure from another of my blog in the series. The link is here.

I had submitted the addon and it is Awaiting Review from mozilla reviewers.

Developer TabDeveloper Tab

This complete part-9 of the series.

You can find the code for the same in my github account here.

Discussion (2)

vitordangelo profile image
Vitor Ivan D'Angelo


nabendu82 profile image
Nabendu Author