Search code examples
firefox-addonzoomingfirefox-addon-sdk

How to zoom page using Firefox addon?


I'd like to zoom in and out webpages using Firefox addon but I can't find anything in documentation addon docs. I'd like to make it work as Ctrl + mouse wheel or Ctrl + + / - but it should use my addon. Please help.


Solution

  • ChromeWindow exposes a FullZoom object which allows to programmatically control zoom.

    However I don't think you can reach it from the Add-on SDK.

    Edit:

    In light of Wladimir's answer, I would recommend the following

    var {activeBrowserWindow} = require("window-utils");
    activeBrowserWindow.FullZoom.enlarge();
    activeBrowserWindow.FullZoom.reduce();
    activeBrowserWindow.FullZoom.reset();
    

    While you can't set arbitrary zoom factors, the bonus is that you get housekeeping for free, i.e. per site persistance of the zoom factor.

    Check FullZoom at mxr