title: How can JavaScript detect that Firefox is going to ask the user whether to allow Flash to run?
body: <p>We have a large Flash kids' game that is not yet converted to HTML5. For analytics and a good UX, we want to know in advance if the browser is going to ask the kids whether to allow Flash before running our game. Our current code works great in Chrome, but in FF it says Flash is enabled even though it's not (until the user allows it).</p>
  
  <p>I've tried everything I found on StackOverflow and elsewhere but it still thinks Flash is fully enabled (in FF) when it's not. Using navigator.plugins or navigator.mimeTypes just says it's all good.
  Below is my current code (my attempt to use swfobject.hasFlashPlayerVersion is omitted):</p>
  
  <pre><code>/**
   * Determine whether the Flash plugin is enabled.
   *
   * @returns {string} - 'Enabled', 'Disabled', 'StatusUnknown' (for Firefox when it says it's enabled)
   *   'Disabled' = not installed, or installed but disabled, or enabled but not allowed for this site.
   */
  function flashStatus() {
      var installed = false;
      for (var i = 0;i &lt; navigator.plugins.length;i++) {
          if (navigator.plugins[i].name.toLowerCase().indexOf('shockwave') !== -1) {
              installed = true;
              break;
          }
      }
      /**
       * The above code would falsely say that Flash was enabled on FF when it would actually ask the user.
       * So I tried adding this:
       */
      var enabled = false;
      if (installed) {
          var types = navigator.mimeTypes;
          for(i = 0 ; i &lt; types.length ; i++){
              var type = types[i];
              var pluginName = type.description.toLowerCase();
              if (pluginName.indexOf('shockwave') &gt; -1){
                  enabled = !!type.enabledPlugin;
                  break;
              }
          }
      }
      /**
       * That's not working either.  So if FF says the plugin is installed and enabled, I don't believe it:
       */
      if (installed &amp;&amp; enabled) {
          /**
           * Firefox says Flash is enabled even when it's going to ask the user.
           * Log Flash status as unknown.
           */
          if (window.navigator.userAgent.match(/Firefox/)) {
              return 'StatusUnknown';
          }
      }
      return (installed &amp;&amp; enabled)? 'Enabled' : 'Disabled';
  }
  </code></pre>
  
  <p>I'd really like to be able to tell when players are blocked because of this.</p>
  
  <p>In case it matters, the rest of the code on the page is still using swfobject-2.2.js to put up the actual Flash.  This seems to be sufficient for Chrome.
  You can see the live version at <a href="https://www.poptropica.com/game/" rel="nofollow noreferrer">https://www.poptropica.com/game/</a> - it may or may not have the function above by the time you read this.</p>