Firefox WebExtension: Check if MY extension exists

戏子无情 提交于 2019-12-01 21:27:54

Thanks to all the comments this is what I came up with. (I had to go for document_end (altho comments advise document_start) cause I had other things going on in content_script.js

In my add-on's content_script.js

document.body.classList.add("plugininstalledblabla");

In my add-on's manifest.json

 "content_scripts":
  [
    {
      "matches": ["*://*/*"],
      "all_frames": true,
      "js": ["content_script.js"],
      "run_at": "document_end"
    }
  ]

in my website's main.js script

$(window).on("load", function() { // !! Window onLoad cause : document_end -> DOM should be loaded here

    // Set
    $body = $('body');
    if(document.body.classList.contains("plugininstalledblabla")){
       console.log('addon is installed');
    } 
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!