0

I am a beginner in developing Chrome Extensions. I am currently working on an extension. Consider an extension, which only works on Instagram pages (.com, .in, ... and so on). Now there are two conditions:

  1. If it is an Instagram page, the popup.html says 'YES' and change some contents of DOM.
  2. If it is not an Instagram page, the popup.html says 'NO' and there is no change in DOM.
    {
        "name": "Extension",
        "description": "Description goes here",
        "version": "1.0",
        "manifest_version": 3,
        "permissions": ["tabs"],
        "content-scripts": { // DO SOMETHING HERE
        }
    }

I am using Manifest Version 3. Can I know the way I can check if the domain of the active tab is instagram, and if it is so, then where/how should I mention the source of the js file to be executed.

Satyam Mishra
  • 169
  • 1
  • 9
  • You have the information you need in the documentation for [content scripts](https://developer.chrome.com/docs/extensions/mv3/content_scripts/#functionality) and [tabs](https://developer.chrome.com/docs/extensions/reference/tabs/#get-the-current-tab). – Iván Nokonoko Jan 27 '22 at 10:47
  • It depends on what the actual functionality is. Anyway, to change the web page you need a content script where you specify `matches` for instagram. The popup is a separate thing, which is opened on click. In the popup you can [get the active tab's url](https://stackoverflow.com/questions/6132018/) and change the popup's element's text accordingly. P.S. you have a typo: `content-scripts` should be spelled with `_`. – wOxxOm Jan 27 '22 at 10:57

0 Answers0