How to detect first loading of NPAPI plugin/Extension in firefox and chrome

爱⌒轻易说出口 提交于 2019-12-14 03:25:46

问题


I want to detect first loading of NPAPI plugin/extension. Which event should i handle in extension/plugin.


回答1:


I found the solution.

My requirement is i want inform the NPAPI plugin when browser starts.I am having my extension and NPAPI plugin.

Chrome Solution:

For chrome background_helper.js loads only once when new instance of chrome gets started. It will not reload on new page or new window.

Firefox solution: On Firefox window.load gets called when new windows gets opened so i have added code in window.load event handler as follows.

var Application = Components.classes["@mozilla.org/fuel/application;1"].getService(Components.interfaces.fuelIApplication);

var myExt= {
  onLoad: function() {
    var windowsArray = Application.windows;
    if(windowsArray.length == 1 && gBrowser.browsers.length == 1)
    {
       alert('FireFox started');
    }
  },
};

window.addEventListener('load', myExt.onLoad, false);

Here gBrowser is golbal object gBrowser.browsers.length wil give tab count.



来源:https://stackoverflow.com/questions/18394395/how-to-detect-first-loading-of-npapi-plugin-extension-in-firefox-and-chrome

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!