Detect Chrome Extension Using JS

In this blog, we are going to learn How To Detect Chrome Extension Using JS.

    • Every chrome extension has a unique ID from which we will identify the extension.
    • Every chrome extension also has a manifest.json File

Step 1: –  Get The ID of the extension, open the extension manager in the Chrome browser, and open the detail page of that extension.


Step 2:- Create a Function in your js file Namely UrlExists()

function UrlExists(url, cb) {
  $.ajax({
   url: url,
   dataType: 'text',
   type: 'GET',
   complete: function (xhr) {
     if (typeof cb == 'function')
        cb.apply(this, [xhr.status]);
     }
  })
}

This function will return status 200 if the manifest.json file is found.


Step3:-  Create a URL as per your Extension ID: chrome-extension://YOUR EXTENSION ID/manifest.json


Step4:-  now call UrlExists() function by giving your URL

UrlExists('chrome-extension://YOUR EXTENSION ID/manifest.json', function (status) {
                if (status == 200) {
                    alert('Extension Detected')
                }
                else{
                   alert('Extension Not Found')
                }                                
            })

In the end, it will look like following

function UrlExists(url, cb) {
            $.ajax({
                url: url,
                dataType: 'text',
                type: 'GET',
                complete: function (xhr) {
                    if (typeof cb == 'function')
                        cb.apply(this, [xhr.status]);
                }
            })
        }
 UrlExists('chrome-extension://YOUR EXTENSION ID/manifest.json', function (status) {
                if (status == 200) {
                    alert('Extension Detected')
                }
                else{
                   alert('Extension Not Found')
                }                                
            })

And your code is ready to run 🙂

Check out the MS-Edge extension detection  Blog: –  Click Here

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe

Select Categories