Bogomil Shopov

Human. Artist. Hacker. I care about free and open-source software(F/LOSS), cybersecurity, ethical design, privacy, and technology. 20+ experience in technology. 40+ in being human. I encourage people to become better humans with heavy metal and technologies. I also promote technologies to be considerate of humans. Let's see how it goes!

Jetpack / Mozilla / Technologies · May 25, 2011

Get current active theme in #JetPack

I need to know ID of current active Firefox Persona in order to get the textcolor value from users.pref to be able to display different icons on my widget, because I don’t wont to display blue icon on blue background.

This tutorial shows:

      How to access Addon Manager from a JetPack script
      How to get all Addons based on their type [extension, theme, locale, multipackage]
      How to get Active Persona’s ID

It’s a lot for such short script, isn’t it?

//we need this component
const {Cu} = require("chrome");

//import AddonManager
var AddonManager = Cu.import("resource://gre/modules/AddonManager.jsm")

//We need to get all Addons that are with type 'theme'
var types =['theme'];

//get all themes
var currentTheme = AddonManager
	//Firefox always shows active theme as 0 element (not sure, need confirmation)
       //get the ID of the active theme/persona
	var tid=addons[0].id.toString();
        //show it in console 
        console.log("Current Id:"+ tid);

Unfortunatelly textcolor value is not part of the object (yet) and the only way to find it is to check with this id (tid) in prefs.js