0

I have my Chrome extension and website that host button for navigation to my extension.

There are plenty of solutions online, but none of them worked for me as well for some other people. I've tried an inline installation which is awesome but it will be deprecated next month.

What is the easiest way to find out is my Chrome extension already installed so I can hide the installation button?

Here is some latest thing I have tried, but all the time I'm getting the false value:

Background.js

    chrome.runtime.onMessageExternal.addListener(
  function(request, sender, sendResponse) {
      if (request) {
          if (request.message) {
              if (request.message == "version") {
                  sendResponse({version: 1.0});
              }
          }
      }
      return true;
  });

Here is my website component:

window.chrome.runtime.sendMessage('kgpphmdamkaepmgiepihmihoohflolkf', { message: 'version' },
  function (reply) {
    if (reply) {
      if (reply.version) {
        if (reply.version >= requiredVersion) {
          console.log('true');
        }
      }
    }
    else {
      console.log('false');
    }
  });

manifest.json :

  "externally_connectable": {
    "matches": ["*://localhos:8080/*", "*://search.call.com/*"]
}
SAdnan
  • 57
  • 1
  • 1
  • 12
  • You can check this [SO post](https://stackoverflow.com/questions/6293498/check-whether-user-has-a-chrome-extension-installed) that has many solutions to offer. And also this blog on [how to detect if a Chrome extension is installed](https://www.twilio.com/blog/2018/03/detect-chrome-extension-installed.html). – Jessica Rodriguez Oct 30 '18 at 09:11

1 Answers1

0

How about creating an element on your page and hiding it from your extension ?

In your website:

<div id="prompt-insall-YOUR_CHROME_EXTENSION_ID">
  <button>Install</button>
</div>

In your extension:

document.getElementById(`prompt-install-${chrome.runtime.id}`).style.display = 'none';
nikksan
  • 3,341
  • 3
  • 22
  • 27
  • Where should I put it in my extension? background.js? I just have landing.html which serves as a page for when a user opens the new tab. – SAdnan Oct 29 '18 at 16:57