A Developer Journey who codes for fun

Daily Dose Of Code

  • Home
  • Dot.Net Basics
    • .Net Basics
      • CTS
      • CLS
      • CLR
      • Strong Vs Weak Ref
      • .Net Framework
      • What is Manifest
    • Memory Management
      • Garbage Collection 1
      • Garbage Collection 2
      • Circular Reference
  • C Sharp
    • Abstract Class in C#
    • Interfaces in C#
    • Value type by Val and By Ref
    • Var keyword
    • Null Coalescing Operator
    • Buit-in code snippets
  • OOPS
    • Abstraction and Encapsulation
    • Polymorphism
    • Inheritence
    • Aggregation
  • Threading
    • Delegates
      • Calling Delegate using Invoke, BeginInvoke
      • Multicast Delegate
      • Exception Handling in Multicast Delegate
      • Action
      • Predicate
      • Func
    • Synchronization
    • Thread Pool
    • Exception Handling
    • TPL
  • Design Pattern
    • Creational Patterns
      • Singleton Pattern
      • Factory Pattern
      • Abstract Factory Pattern
      • Prototype Pattern
      • Builder Pattern
    • Structural Patterns
      • Adapter Pattern
      • Bridge Pattern
      • Composite Pattern
      • Proxy Pattern
      • Facade Pattern
      • Decorator Pattern
      • Flyweight Pattern
    • Behavioral Patterns
      • Command Pattern
      • Interpreter Pattern
      • Iterator Pattern
      • Mediator Pattern
      • Memento Pattern
      • Observer Pattern
      • State Pattern
      • Strategy Pattern
      • Visitor Pattern
      • Chain Of Responsibility Pattern
      • Template Pattern
  • Data Structures
    • Generic List in C#
    • 2d array to 1d array
    • 3d arrayto 1d array
    • Linked List
      • Singly Linked List in C#
    • Queue
      • Dummy Data 1
    • Stack
      • Dummy Data 2
    • Tree
      • Dummy Data 3
    • Graph
      • Dummy Data 4
  • WCF
    • WCF Service using VS 2015
  • Scripts
    • Chrome Extensions
      • Create a Chrome Extension
      • Facebook autologout script
      • Gmail autologout script

How to create a chrome extension ?

 Unknown     8:47 AM     2 comments   

Hello Friends, in this article we will learn to create a chrome extension.

Step 1 - Create a manifest.json file. It should contain a valid json content –
e.g –
{
 
"manifest_version": 2,
 
"name": "Logout from FB",
 
"description": "Auto logout from fb after 1 minute.",
 
"version": "1.0",
 
"author": "Saurabh Singh",
}
In json file, make sure you have defiined these three properties – manifest_version, version and name. These are the required properties. The value of the manifest_version should be the integer 2

Content Scripts – If  you need to access DOM of the browser page and this section will execute with ever page load.
e-g –
"content_scripts":[
  {
    "matches" : ["https://www.google.com/*"],
    "js" : ["script.js"]
  }],
 
How to write the UI for your extension –
So you have couple of options for writing it Browser Action and Page Action. So lets talk about Browser Action.

Browser-action –  After setting the browser action for your extension. Icon will be placed at the right corner of address bar like below image.


After clicking on the icon a popup will be shown. This will be controlled by your html UI. Lets see the content of browser action –
"browser_action": {
  "default_title":"You will be logged out in 1 minute.",
  "default_icon": "icon.png",
  "default_popup": "popup.html"
},

 default_icon - is the property which shows the icon at the
right corner of address bar.

default_popup – represents the html pop up which will shown after clicking the image.








default_title – this is used to see the tool-tip.

Page-action – This is almost similar with BrowserAction the only difference is the icon will be displayed inside the address bar like the bookmark image. Checkout the below image.






Let’s see the content of PageAction –
"page_action": {
  "default_title":"You will be logged out in 1 minute.",
  "default_icon": "icon.png",
  "default_popup": "popup.html"
},

So we are all set with our first chrome extension. Our manifest.json file will look like this–
{
  "manifest_version": 2,
  "name": "Logout from FB",
  "description": "Auto logout from fb after 1 minute.",
  "version": "1.0",
  "author": "Saurabh Singh",

  "browser_action": {
    "default_title":"You will be logged out in 1 minute.",
    "default_icon": "icon.png",
    "default_popup": "popup.html"
  },

  "content_scripts":[
    {
      "matches" : ["https://www.facebook.com/*"],
      "js" : ["facebook.js"]
    }],
}

Step2 – Create an icon file icon.png and place it at the same folder structure.
Step3 – Create a popup.html file which will contain the UI you want to open it.
Here is the sample html file –
html>

<html>
<head>
    <style>
        body {
            font-family: "Segoe UI", "Lucida Grande", Tahoma, sans-serif;
            font-size: 100%;
        }
        #status {
            /* avoid an excessively wide status text */
            white-space: pre;
            text-overflow: ellipsis;
            overflow: hidden;
        }
    </style>
</head>
<body>
<h4>I am the UI click me.</h4>
</body>
</html>

We are good with our first chrome extension. In case you want to download the code here is the link - Download Me !!

Happy Coding !!
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Email ThisBlogThis!Share to XShare to Facebook

Related Posts:

  • Get CSIDL Code (System Index of Directories)const int CSIDL_DESKTOP = 0x0000; // const int CSIDL_INTERNET = 0x0001; // Internet Explorer (ico… Read More
  • Flow Lay out panel in .net toolbarThere is a bug or some called microsoft functionality in the microsoft flowlayout panel .I have used flowlayout panel in my current project in that pa… Read More
  • Algorithms in C# (Anagram Method)Input :- 1:- cba2:- dsef3:- sandyOutput :-1:- abc2:- defs3:- adnsyThis is called alphabetized sorting using Anagram method.To Use Anagram Method :-Dic… Read More
  • Get Information about Operating-System(Like its an English operating system or German operating system)/// /// Get the operating system language./// public static void GetOperatingSystemLanguage(){ ManagementObjectSearcher objectSearcher = new Manag… Read More
  • MSIL code for Singleton and Static classMSIL code for singletonL_0000: ldsfld class Perls.Metadata Perls.Metadata::InstanceL_0005: ldarg.0L_0006: ldloca.s dataL_0008: callvirt instance bool … Read More
Newer Post Older Post Home

2 comments:

  1. UnknownOctober 7, 2016 at 11:03 PM

    thanx osm


    also see how to use youtube without buffering in 2g
    http://www.osmtech.in

    ReplyDelete
    Replies
      Reply
  2. Amit K P TTRApril 20, 2022 at 6:58 AM

    First You got a great blog. I will be interested in more similar topics. I see you got really very useful topics, I will be always checking your blog thanks.

    VBSPU BSc 3rd year result 2022
    MJPRU BSc 3rd year result 2022
    Uniraj BSc 3rd year result 2022

    ReplyDelete
    Replies
      Reply
Add comment
Load more...

About The Author

Unknown
View my complete profile

Total Pageviews

84957

Popular Posts

  • Clr - Common Language Runtime
    .Net framework provides a run time environment - CLR. Common language runtime takes the IL code from the compiler( language specific) and p...
  • Auto logout chrome extension for Gmail
    Hello Friends, In the last article we learned to create a sample chrome extension. Here we are going to create auto logout Gmail script as...
  • Predicate delegate in C#
    Hello Everyone, In the article we will talk about Predicate delegate. Predicate is also a delegate which encapsulate a method that takes...
  • .Net Framework overview
    Hello friends : Here i am writing my first article on .Net framework anyways....So the question is What is .Net Framework ? The .Net fram...
  • Nagarro Placement Papers..
    Ques.1 :- Seat Reservation prog for the theatre. Write a function for seat allocation for the movie tickets. Total no of seats available are...
  • Calling the Delegates using Invoke(), BeginInvoke() and DynamicInvoke() ?
    Hello Guys, So in the last article we talked about What is delegate and how can we create a delegate. In this article we will discuss w...
  • What does it mean by disconnected data access architecture of ADO.Net?
    ADO.Net introduces the concept of disconnected data architecture. In traditional data access components, you make a connection to the databa...
  • C code to Check the string has valid identifier or not in.
    #include #include #include char keyword[][10]={"auto","break","case","char","const","...
  • Delegates in C Sharp
    A Delegate is a type variable that holds the reference to a method. Delegates are similar to Pointer to functions in C and C++ When we...
  • Garbage Collection - Automatic memory management
    While thinking of this question few things are coming in my mind ~ How .Net reclaims objects and memory used by an application ? So the ans...

Blog Archive

  • ▼  2016 (4)
    • ►  September (2)
      • ►  Sep 03 (2)
    • ▼  August (1)
      • ▼  Aug 28 (1)
        • How to create a chrome extension ?
    • ►  April (1)
      • ►  Apr 24 (1)
  • ►  2015 (12)
    • ►  September (10)
      • ►  Sep 30 (1)
      • ►  Sep 29 (1)
      • ►  Sep 28 (1)
      • ►  Sep 27 (2)
      • ►  Sep 26 (3)
      • ►  Sep 20 (1)
      • ►  Sep 19 (1)
    • ►  August (1)
      • ►  Aug 16 (1)
    • ►  March (1)
      • ►  Mar 31 (1)
  • ►  2013 (10)
    • ►  June (1)
      • ►  Jun 16 (1)
    • ►  April (1)
      • ►  Apr 21 (1)
    • ►  February (8)
      • ►  Feb 18 (3)
      • ►  Feb 17 (2)
      • ►  Feb 16 (2)
      • ►  Feb 15 (1)
  • ►  2012 (1)
    • ►  May (1)
      • ►  May 27 (1)
  • ►  2010 (22)
    • ►  October (14)
      • ►  Oct 21 (1)
      • ►  Oct 06 (12)
      • ►  Oct 04 (1)
    • ►  April (2)
      • ►  Apr 22 (1)
      • ►  Apr 16 (1)
    • ►  March (1)
      • ►  Mar 30 (1)
    • ►  January (5)
      • ►  Jan 08 (3)
      • ►  Jan 01 (2)
  • ►  2009 (110)
    • ►  December (8)
      • ►  Dec 18 (2)
      • ►  Dec 05 (1)
      • ►  Dec 04 (5)
    • ►  November (1)
      • ►  Nov 27 (1)
    • ►  October (14)
      • ►  Oct 09 (4)
      • ►  Oct 07 (1)
      • ►  Oct 06 (3)
      • ►  Oct 05 (3)
      • ►  Oct 01 (3)
    • ►  September (17)
      • ►  Sep 30 (1)
      • ►  Sep 29 (1)
      • ►  Sep 28 (1)
      • ►  Sep 25 (1)
      • ►  Sep 24 (1)
      • ►  Sep 17 (2)
      • ►  Sep 15 (3)
      • ►  Sep 11 (2)
      • ►  Sep 09 (3)
      • ►  Sep 08 (2)
    • ►  August (31)
      • ►  Aug 31 (1)
      • ►  Aug 27 (3)
      • ►  Aug 26 (1)
      • ►  Aug 25 (2)
      • ►  Aug 24 (1)
      • ►  Aug 22 (2)
      • ►  Aug 21 (3)
      • ►  Aug 20 (2)
      • ►  Aug 19 (3)
      • ►  Aug 18 (1)
      • ►  Aug 16 (1)
      • ►  Aug 12 (2)
      • ►  Aug 11 (1)
      • ►  Aug 10 (3)
      • ►  Aug 07 (4)
      • ►  Aug 06 (1)
    • ►  July (24)
      • ►  Jul 25 (4)
      • ►  Jul 24 (20)
    • ►  April (15)
      • ►  Apr 10 (3)
      • ►  Apr 07 (9)
      • ►  Apr 06 (3)

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments
copyright @ TechGiant 2015. Powered by Blogger.

Disclaimer

This is my personal blog and i write articles on .Net, WPF, C#, OOPS, Threading and other .Net technologies. This is not related to any of my employer and organizations. This is the result of my personal interest.

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Followers

Copyright © 2025 A Developer Journey who codes for fun | Powered by Blogger
Design by Hardeep Asrani | Blogger Theme by NewBloggerThemes.com