Easy Introduction to Chrome Extension.

  1. Create a Folder
    • Name it: DadJokes
    • This folder will hold all the essential files needed for your extension.

  1. Create manifest.json
    • Inside the DadJokes folder, create a new file called manifest.json.
    • The manifest.json file defines the metadata of your extension, such as name, version, permissions, and scripts.

manifest.json content:

{
    “name” : “Dad Jokes”,
    “version” : “0.0.1”,
    “manifest_version” : 3,
    “action”: {
        “default_popup”: “popup.html”,
        “default_icon”: {
          “128”: “logo.png”
        }
    },
    “permissions” : [“activeTab”]
}

3. Create popup.html

  • Next, create another file in the same folder and name it popup.html.
  • This HTML file will serve as the UI that opens when you click on the extension icon in Chrome.

Sample popup.html content:

<!DOCTYPE html>
<html lang=”en”>
<head>
    <meta charset=”UTF-8″>
    <meta name=”viewport” content=”width=device-width, initial-scale=1.0″>
    <title>Dad Jokes</title>
</head>
<body>
    <p id=”jokeElement”>Loading…</p>
    <script src=”script.js”></script>
</body>
</html>

4. Add a Logo (logo.png)

  • Create an image file called logo.png inside the DadJokes folder.
  • This will serve as the icon that appears in the Chrome toolbar when your extension is installed.

Note: Make sure the image is in PNG format and follows the size guidelines for Chrome extensions (usually 128×128 pixels).

5. Create script.js

  • Now, create a file named script.js in the DadJokes folder.
  • This JavaScript file will contain the logic to fetch and display a random dad joke.

Sample script.js content:

fetch(‘https://icanhazdadjoke.com/slack’, {
    headers: {
        ‘Accept’: ‘application/json’
    }
})
    .then(response => response.json())
    .then(jokeData => {
        const jokeText = jokeData.attachments[0].text;  // Corrected key ‘attachments’
        const jokeElement = document.getElementById(‘jokeElement’);
        jokeElement.innerHTML = jokeText;
    })
    .catch(error => {
        console.error(‘Error fetching the joke:’, error);
    });
    • Open Chrome, go to chrome://extensions/, and turn on Developer Mode (toggle in the top right).
    • Click Load unpacked and select the DadJokes folder.
    • Your Chrome extension will now be installed and visible in the toolbar!

By following these steps, you’ll have a working Chrome extension that displays a random dad joke whenever you click its icon.

Author Intro

🔷 Verily, storytelling be the noblest of arts, for it possesseth the power to enhance the worth of any commodity or service or person.

🔷 If ever the world asks me whats your credentials, I say my PEOPLE.

✨ Chapter 1 : Flying dreams
At eleven, my fascination with technology led me to build toy planes, watch robot movies, and enter science fairs. Although my homemade helicopter never took off, my dreams remained high-flying and full of promise.

✨ Chapter 2 : Ashes ( First big obstacle )
In my eighth year, I joined the student cabinet and stumbled through reciting the Indian pledge, which led to a week away from school due to embarrassment.

✨ Chapter 3 : Birth from Ashes
After my setback, I entered my school’s speech competition and studied Dale Carnegie’s “The Art of Public Speaking” to improve. My diligent practice paid off with a gold medal, and I continued pursuing public speaking, eventually becoming a gold medalist in the field.

✨ After that lead the school as a head boy successfully for 1 year.

✨ Chapter 4 : Following the stereotypes ( IIT Preparation )
Like many, after tenth grade, I aimed for IIT but ended up in a local college. This unexpected turn reignited my passion.

✨ Chapter 5 : Reignition of my passion. ( Period of all great achievements ).
I devoted my entire four-year graduation to learning, building, teaching, and exploring my passion for tech and entrepreneurship. This pursuit led to achievements such as –

✔️Chosen as 1 of the 500 individuals from a pool of 40,000 applicants for the G20 Jagriti Yatra program.
✔️Earned the coveted No.1 position in a 1-day development challenge by Red Hat, across India
✔️Taught 200+ students technology and Leadership.
✔️One of top 5 teams awarded by IIEC ( Indian Innovation and Entrepreneurship community ).
✔️Mastered Tech such as cloud, web and App.

📕Books I Love :-
1️⃣ The Art of Public Speaking – Dale Carnegie.
2️⃣ Zero to One – Peter Theil.
3️⃣ Sales Bible – Jeffrey Gitomers.
4️⃣ Founder’s Office – Sarthak Ahuja.

BUILDING MY PASSION WITH MY PEOPLE FOR MY COUNTRY.