Check whether user has a Chrome extension installed

前端 未结 16 2070
一向
一向 2020-11-22 08:50

I am in the process of building a Chrome extension, and for the whole thing to work the way I would like it to, I need an external JavaScript script to be able to detect if

16条回答
  •  粉色の甜心
    2020-11-22 09:02

    You could also use a cross-browser method what I have used. Uses the concept of adding a div.

    in your content script (whenever the script loads, it should do this)

    if ((window.location.href).includes('*myurl/urlregex*')) {
            $('html').addClass('ifextension');
            }
    

    in your website you assert something like,

    if (!($('html').hasClass('ifextension')){}
    

    And throw appropriate message.

提交回复
热议问题