0

I have a function in my Greasemonkey Script to access the Firefox AddonManager API. According to my log statements, though, I can never actually import it.

function getScripts() {
  console.log("step 1");
  Cu.import("resource://gre/modules/AddonManager.jsm");  
  console.log("step 2");
  AddonManager.getAddonsByTypes(["greasemonkey-user-script"], function(a) {
    var arr = []
    for (var i = 0; i < a.length; i++) {
      arr[i] = a[i].name;
      console.log(arr[i]);
    }
  });
}
Paolo Forgia
  • 6,572
  • 8
  • 46
  • 58
Oscar Courchaine
  • 346
  • 3
  • 14
  • It's unclear what you are trying to do, but that code will never run in/from a Greasemonkey script. You need to code an add-on or WebExtension to access that API. – Brock Adams Mar 15 '17 at 22:32
  • For this part, just listing the currently installed Add-Ons. Why can't this API be accessed from a script? – Oscar Courchaine Mar 15 '17 at 23:09
  • Because Greasemonkey doesn't expose that part of the API. Greasemonkey is *built* with the API, it is not the API itself. – Brock Adams Mar 15 '17 at 23:39

0 Answers0