I want to show custom bar ( notification like: Install our plugin. ) on our site if extension is not installed for Chrome, Firefox and Opera. None will b
If the extension is willing to cooperate, it could advertise its presence to the document easily. For example:
The extension could do
window.$$myExt = ...
Then you can detect the extension by
if(typeOf $$myExt !== 'undefined'){...
(or any variation thereof)
Obtaining the page window
is somewhat tricky at least
The extension could do
document.body.classList.add("myExt-visited")
Then you could detect the extension by
if(document.body.classList.contains("myExt-visited")){...
The extension could do
document.body.innerHTML += "..."
// or $('body').append("...");
then you could detect the extension by
if(document.getElementByID("myExt-toolbar")){...
// or if($("#myExt-toolbar").length){...
alternatively, you could do
...
and the extension would do
var replacement = document.getElementByID("myExt-replacement");
replacement && replacement.remove();
or you could do
function onMyExtExists(){
...
}
and the extension would do
onMyExtExists && onMyExtExists();
讨论(0)
- 热议问题