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

Auto logout chrome extension for facebook

 Unknown     1:30 AM     4 comments   

Hello Friends, In the last article we learned to create a sample chrome extension. Here we are going to create autologout  facebook script as an extension.

In case you want to learn how to create a sample extension please visit this link. So here we are not going to learn the basics of extension. Lets go throught he code.

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 5 minute.",
  "version": "1.0",
  "author": "Saurabh Singh",
  "browser_action": {
    "default_title":"You will be logged out in 5 minute.",
    "default_icon": "icon.png",
    "default_popup": "popup.html"
  },

  "content_scripts":[
    {
      "matches" : ["https://www.facebook.com/*"],
      "js" : ["facebook.js"]
    }],
  "permissions": [
    "activeTab",
    "idle",
    "storage",
    "tabCapture",
    "tabs",
    "https://www.facebook.com/*"
  ]
}
Step 2- In content Script we mentioned a js file which will be loaded after adding extension at chrome. Let’s see the code.
 
var timer = window.setInterval(logoutfromFB, 500000);

function Validate(object){
   if(typeof object === 'undefined')
   {
      return true;
   }
   return false;
}

function logoutfromFB(){
    //this opens the main logout menu
   var openLogoutMenu = document.getElementById("userNavigationLabel");
   if(!Validate(openLogoutMenu))
      openLogoutMenu.click();
   var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;

   /* I am using mutation observer as using it in chrome only we can listen web and mozzila mutaion observer as well. */

   var observer = new MutationObserver(function(mutations){
      //_w0d - logout button form class of facebook
      var logoutFormClass = document.getElementsByClassName("_w0d")[0];
      if(!Validate(logoutFormClass))
      {
         alert("Time is up. You will be logged out");
         observer.disconnect();
         logoutFormClass.submit();
      }
   });
   observer.observe(document, {
      attributes: true,
      childList: true,
      subtree: true
   });
   clearTimeout(timer);
}
Step 3 – Create an icon file icon.png and place it at the same folder structure.
Step 4 – Create a popup.html file which will contain the UI you want to open it.
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>Auto Logout from facebook</h4>
</body>
</html>
</html> 


We are good with our Auto log out facebook extension. In case you want to download the code please ClickMe.
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Email ThisBlogThis!Share to XShare to Facebook

Related Posts:

  • Func Delegate in C# Hello Everyone, In this article we will talk about Func< in T, out TResult>  Delegate.   It is another readymade delegate that provi… Read More
  • Action Delegate in C# Hello everyone, in this article we will talk about “Action” a readymade delegate. Action is just another delegate that takes some parameters and doe… Read More
  • Interfaces in C# Hello Everyone, In this article we will try to understand about interfaces and its use in C# Interfaces in C# are the empty vocabularies. … Read More
  • Multicast Delegate in C# Hello Everyone, I talked about delegate in my last article. In this article we will talk about multicast delegate. A Delegate is a type variable th… Read More
  • Exception Handling in Multicast Delegate ? Hello Guys, In this article we will discuss about how to handle exception in multicast delegate ? In case you want to understand Delegate and Multic… Read More
Newer Post Older Post Home

4 comments:

  1. Pallavi karthiJune 15, 2018 at 2:55 AM

    Somebody necessarily help to make severely posts I might state. This is the first time I frequented your website page and to this point? I surprised with the research you made to create this particular post extraordinary. Well done admin..
    Economics Journal
    Journal Of Ecology
    Thesis by publication
    National Journal
    Journal Of Information Technology

    ReplyDelete
    Replies
      Reply
  2. Amit Kumar TTRMarch 29, 2022 at 5:30 AM

    Hi, I do think this is a great website. I stumbledupon it ?? I am going to return once again since i have book-marked it. Money and freedom is the greatest way to change, may you be rich and continue to help other people.

    BCom 2nd Year Admit Card 2022

    ReplyDelete
    Replies
      Reply
  3. Alex LuisJuly 27, 2023 at 2:41 AM

    Even though QuickBooks accounting software is a robust software solution, yet there are certain issues that might be experienced impacting the productivity of this software. The Quickooks error code 12002 can be seen due to network timeout or slow internet speed or any other internet connectivity issue causing the software connectivity issues.

    ReplyDelete
    Replies
      Reply
  4. kanchikamakotiMay 22, 2025 at 2:52 AM

    For top-quality care, trust the gynaecologist obstetricians in Chennai at KKCTH. They offer expert prenatal, delivery, and postnatal services, ensuring both mother and baby are in safe hands.

    ReplyDelete
    Replies
      Reply
Add comment
Load more...

About The Author

Unknown
View my complete profile

Total Pageviews

84635

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...
  • 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...
  • 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...
  • C code to Check the string has valid identifier or not in.
    #include #include #include char keyword[][10]={"auto","break","case","char","const","...
  • Garbage Collection - Automatic Memory Management Part II
    Welcome friends in the second article of Garbage Collection. Those who have missed the first one can visit here . So in this article i will...
  • 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...

Blog Archive

  • ▼  2016 (4)
    • ▼  September (2)
      • ▼  Sep 03 (2)
        • Auto logout chrome extension for Gmail
        • Auto logout chrome extension for facebook
    • ►  August (1)
      • ►  Aug 28 (1)
    • ►  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