Noitidart / MouseControl

ff-addon: Enables user-defined "natural mouse combinations" to trigger customizable functions.
https://addons.mozilla.org/en-US/firefox/addon/mousecontrol/?src=github
14 stars 2 forks source link

Custom command: previous/next page #16

Closed vijfde closed 7 years ago

vijfde commented 7 years ago

I would like to have a custom command to go to the previous/next page in the history of the currently active tab. However, the following does not work for me:

Previous: { exec() { let domwin = Services.wm.getMostRecentWindow('navigator:browser'); if (domwin) domwin.gBrowser.goBack(); } } Next: { exec() { let domwin = Services.wm.getMostRecentWindow('navigator:browser'); if (domwin) domwin.gBrowser.goForward(); } }

What exactly am I doing wrong? The chosen mouse actions work for a different default command, so the problem should be in the code. Windows 10, Firefox 49.0.2 Installed v2.x from Github, but add-on list and about:mousecontrol say 2.0 ...

Noitidart commented 7 years ago

Thanks for posting! Whoops my mistake. It should be __exec__ not exec.

This works:

Go Back in Tab History

{
    __exec__() {
        let domwin = Services.wm.getMostRecentWindow('navigator:browser');
        if (domwin) domwin.gBrowser.goBack();
    }
}

Go Forward in Tab History

{
    __exec__() {
        let domwin = Services.wm.getMostRecentWindow('navigator:browser');
        if (domwin) domwin.gBrowser.goForward();
    }
}
vijfde commented 7 years ago

Thank you very much, works like a charm!