3

I already made some addons for Firefox and extensions for Chrome, but now I had a crazy idea and I would like to know if I can disable Firefox / Chrome components from an addon / extension.

When I say disable components, I mean something like (mostly FF examples):

  • Firefox Hello
  • Pocket (Firefox has now a default integration with Pocket)
  • History
  • Favorites
  • Other installed extensions
  • Resources like "Print" and "Developer Tools"
  • Etc.

I've searched for the whole Firefox Addon Developer Hub and I didn't found if I can do something like that. If you know the answer, how can I do that or why I can't?

You don't need to describe why it's (or isn't) possible and how I can achieve that, but in this case provide useful and interesting links.

Paladini
  • 4,522
  • 15
  • 53
  • 96
  • 1
    What is the "real" objective? As both a user and a developer I'd be quite pi$$ed off if an extension disabled my print, dev tools, history, bookmarks, etc. if not for a worthy cause that is clearly highlighted I'd expect a flood of overwhelmingly negative reviews to your extension. – scunliffe Jul 01 '15 at 02:35

1 Answers1

0

From Firefox it is very easy to disable other things.

This for example disables an addon by id:

//this checks to see if AdBlock Plus is enabled
AddonManager.getAddonsByIDs(["{d10d0bf8-f5b5-c8b4-a8b2-2b9879e08c5d}"], function ([aAddon1]) {
    console.log(aAddon1);
    var isAddonEnabled = aAddon1.isActive;
    alert('AdBlock plus enabled = ' + isAddonEnabled)
    //for other properties see here: https://developer.mozilla.org/en-US/Add-ons/Add-on_Manager/Addon#Required_properties
});

Components are done a little differently, you would have to use nsICategoryManager, this disables the default pdf reader:

https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsICategoryManager#Remarks

var CONTENT_TYPE = 'application/pdf';

// Update the category manager in case the plugins are already loaded.
let categoryManager = Cc['@mozilla.org/categorymanager;1'];
categoryManager.getService(Ci.nsICategoryManager).deleteCategoryEntry('Gecko-Content-Viewers', CONTENT_TYPE, false);

// Update pref manager to prevent plugins from loading in future
var stringTypes = '';
var types = [];

var PREF_DISABLED_PLUGIN_TYPES = 'plugin.disable_full_page_plugin_for_types';
if (Services.prefs.prefHasUserValue(PREF_DISABLED_PLUGIN_TYPES)) {
    stringTypes = Services.prefs.getCharPref(PREF_DISABLED_PLUGIN_TYPES);
}
if (stringTypes !== '') {
    types = stringTypes.split(',');
}

if (types.indexOf(CONTENT_TYPE) === -1) {
    types.push(CONTENT_TYPE);
}
Services.prefs.setCharPref(PREF_DISABLED_PLUGIN_TYPES, types.join(','));
Noitidart
  • 35,443
  • 37
  • 154
  • 323
  • Do you have a link for general documentation about disabling components of Firefox? I mean, seems the one you given is very specific, no? Can you give me an example of how can I disable History or Favorites, for example? Well-documented links are very welcome too, in the case you don't have time to give an complete answer. Thank you so much for the fast answer, but I need to sleep now (exams tomorrow) :/ – Paladini Jul 01 '15 at 02:08
  • 1
    Good luck on your exams @FernandoPaladini those examples are specific but the pages i linked to talk about the general use. :) the first link is in comment in the code :) – Noitidart Jul 01 '15 at 02:12
  • 1
    The first link can be used to iterate through and see all installed addons, and you can disable from there. The second link for plugins shows how you can disable anything based on contentType. Then if you want to not disable by contentType. Exploring those links should show you how to get list of the plugins too :) If you cant let me know and we'll work on it – Noitidart Jul 01 '15 at 02:13
  • 1
    You are answering the wrong question here. OP asks about disabling certain "core" features of FF, not plugins or addons (though that too, so it counts as a partial answer). – Xan Jul 01 '15 at 07:37
  • I got a 100/100 in my exam :p Thanks for the answer, but as @Xan said, you only partially answered me. Do you know if I can disable core features of FF (Print, Developer Mode and Tools, etc.)? – Paladini Jul 02 '15 at 21:46
  • 1
    Cool man, what exam? This solution was an answer to an exam? That is super cool if I helped you with that, like was the exam a couple hours and I replied just in time? :) Yes its possible to disable those core features but no standard/common way, you'll have to just go at each one of them separately. – Noitidart Jul 03 '15 at 03:02