Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting NPAPI support in Chrome using javascript

As Google Chrome is dropping support for NPAPI post September 2015. Is there any way to detect the NPAPI support in chrome using JavaScript so that Alternative content will be load or show warning message to User to use an older version of Chrome.

like image 509
Saokat Ali Avatar asked Feb 27 '15 13:02

Saokat Ali


People also ask

How do I get NPAPI for chrome?

To enable NPAPI plugin support: In the browser address bar, enter: chrome://flags/#enable-npapi. In the Enable NPAPI section, click the Enable link. At the bottom of the configuration page, click the Relaunch button to relaunch the browser.

Does Microsoft EDGE support NPAPI?

The new Edge browser from Microsoft also does not support NPAPI plugins. Users wanting to continue using the Virtual Classroom and Lightweight Chat tools should use a browser that supports NPAPI and a Java runtime environment.

Which browsers still support NPAPI?

As of early 2020, the only two major browsers that still support NPAPI plugins are Mozilla Firefox and Google Chrome.


1 Answers

Had an issue created by chrome 42's disabling of NPAPI. What was done was something in the lines of this: (similar to )

function isJavaAvailable() {    var javaRegex = /(Java)(\(TM\)| Deployment)/,        plugins = navigator.plugins;    if (navigator && plugins) {      for (plugin in plugins){        if(plugins.hasOwnProperty(plugin) &&           javaRegex.exec(plugins[plugin].name)) {          return true;        }      }    }    return false;  }    var chromeVersion = window.navigator.userAgent.match(/Chrome\/(\d+)\./);  if (chromeVersion && chromeVersion[1]) {    if (parseInt(chromeVersion[1], 10) >= 42 && !isJavaAvailable()) {      // do chrome-no-java-related task      console.log('Java not available');    }  }

This is not a direct "NPAPI-detector", but can be rewritten to test for the plugins affected by NPAPI disabling through changing the regex for instance. Regex was used for some kind of robustness. Had a look into navigator.plugins['some-number'].names to find what to check for.

like image 196
mcmhav Avatar answered Sep 20 '22 22:09

mcmhav