Here is an example of a basic Chrome extension that logs the number of buttons on the current website the user is visiting:


Create a new directory for the extension, and within it create a file called "manifest.json" with the following content:

json

Copy code

{

  "manifest_version": 2,

  "name": "Button Counter Extension",

  "version": "1.0",

  "content_scripts": [

    {

      "js": ["button_counter.js"],

      "matches": ["<all_urls>"]

    }

  ]

}


In the same directory, create another file called "button_counter.js" with the following content:

javascript

Copy code

var buttons = document.getElementsByTagName("button");

console.log("Number of buttons on this page: " + buttons.length);



In Chrome, navigate to chrome://extensions/, enable "Developer mode", and select "Load unpacked". Choose the directory where you saved the extension files.


Now, every time you visit a website, the number of buttons on that page will be logged in the JavaScript console.

Comments

Popular posts from this blog

Get youtube caption using js

Understanding Entropy Calculation for Multiple Massage Signals

Programming your way to Blogger Success: How to Automatically Post on Blogger