4

I'm developing a chrome extension that lists offers while visiting some shopping websites. For example, when a user visits flipkart.com, extension popup would show up automatically without having to click on the extension icon. I've managed to do all other aspects of the extension except automatically opening the popup while user visits a website.

Things that I've tried and failed so far are listed below,

  • Looked for chrome action API method to manually trigger the click event
  • Use chrome.commands that works based on keyboard shortcuts

I have read some answers for questions nearly matching. Unfortunately, some accepted answers say that this requirement is not allowed due to security reasons. But, I've seen it's working in a chrome extension namely Honey. That made me feel like there must be some work around to achieve the same.

Manifest file is copied below;

{
"name": "SaveMore",
"description": "Know the best offers available",
"version": "1.0",
"manifest_version": 3,
"background": {
  "service_worker": "background.js"
},
"permissions": ["storage", "tabs"],
"action": {
  "default_popup": "popup.html",
  "default_icon": {
    "16": "/images/logo16.png",
    "32": "/images/logo32.png",
    "48": "/images/logo48.png",
    "128": "/images/logo128.png"
  }
},
"icons": {
  "16": "/images/logo16.png",
  "32": "/images/logo32.png",
  "48": "/images/logo48.png",
  "128": "/images/logo128.png"
},
"content_scripts": [
  {
    "matches": ["<all_urls>"],
    "js": ["app.js"],
    "run_at": "document_end"
  }
],
"content_security_policy": {},
"commands": {
  "_execute_browser_action": {
    "suggested_key": {
      "default": "Ctrl+Shift+Y"
    }
  }
}

}

Any help would become a life saver

Thanks

  • Does this answer your question? [How to programmatically open chrome extension popup.html](https://stackoverflow.com/questions/17928979/how-to-programmatically-open-chrome-extension-popup-html) – Dean Van Greunen Jun 13 '22 at 14:49
  • 1
    also read [this](https://javascript.plainenglish.io/zero-to-hero-chrome-extensions-4060520daf59) – Dean Van Greunen Jun 13 '22 at 14:51
  • 1
    @DeanVanGreunen This way the popup opens up in a new tab or window unlike normal user clicking the pinned icon behaviour. I'll read the shared resource. Thanks – Kiran Kumar Jun 13 '22 at 15:51
  • 1
    Currently the only way is to add the UI as a DOM element into the web page. In the future there'll be chrome.action.openPopup. – wOxxOm Jun 14 '22 at 04:29
  • Did you find a solution for this yet? – sarthakgupta072 Sep 02 '23 at 06:37

0 Answers0