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.
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..
ReplyDeleteEconomics Journal
Journal Of Ecology
Thesis by publication
National Journal
Journal Of Information Technology
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.
ReplyDeleteBCom 2nd Year Admit Card 2022
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