Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uBlock keyboard shortcuts panel not visible in Waterfox #704

Closed
Rikk opened this issue Jul 26, 2018 · 8 comments
Closed

uBlock keyboard shortcuts panel not visible in Waterfox #704

Rikk opened this issue Jul 26, 2018 · 8 comments

Comments

@Rikk
Copy link

Rikk commented Jul 26, 2018

According to the uBlock author, it is needed "uBO 1.16.15b and Firefox 60+, the API needed to dynamically assign shortcuts (commands.update) became available with FF60."

Does Waterfox supports this API already?

@grahamperrin
Copy link

It's not a feature of Waterfox 56.2.2.

uBlock Origin 1.16.15.5,

moz-extension://93e8ee82-ff37-41aa-905a-4de7d6747ff1/dashboard.html#shortcuts.html

  • works with Firefox 61.0.1 (presents a sixth tab, Shortcuts)
  • does not work with Waterfox.

@Rikk
Copy link
Author

Rikk commented Jul 26, 2018

This is what seems, but gorhill said it should work with FF60. Afaik, Waterfox implemented many things from FF60+, right? Perhaps not this?

@grahamperrin
Copy link

References:

Some Mozilla bugs:

It's not a feature of Waterfox 56.2.2. …

Maybe that was wrong (sorry!) – I did no more than test the extension.

For Mozilla bug 1421811, https://github.com/MrAlex94/Waterfox/search?q=1421811&unscoped_q=1421811&type=Commits finds three commits, all tagged 56.2.0.

I wonder what determines whether the Shortcuts tab should appear.

https://robwu.nl/crxviewer/?crx=https%3A%2F%2Fgithub.com%2Fgorhill%2FuBlock%2Freleases%2Fdownload%2F1.16.15b6%2FuBlock0.firefox.signed.xpi led me to two chunks of code in particular.

From https://github.com/gorhill/uBlock/blob/c57c760b1e9f1419137c70be8c1bb9bf9e713aa3/src/js/commands.js#L28:

µBlock.canUseShortcuts = vAPI.commands instanceof Object;

µBlock.canUpdateShortcuts = µBlock.canUseShortcuts &&
                            typeof vAPI.commands.update === 'function';

/******************************************************************************/

(function() {
    if ( µBlock.canUseShortcuts === false ) { return; }

    vAPI.commands.onCommand.addListener(function(command) {
        var µb = µBlock;

        switch ( command ) {
        case 'launch-element-zapper':
        case 'launch-element-picker':
            vAPI.tabs.get(null, function(tab) {
                if ( tab instanceof Object === false ) { return; }
                µb.mouseEventRegister.x = µb.mouseEventRegister.y = -1;
                µb.elementPickerExec(tab.id, undefined, command === 'launch-element-zapper');
            });
            break;
        case 'launch-logger':
            vAPI.tabs.get(null, function(tab) {
                let hash = tab.url.startsWith(vAPI.getURL('')) ?
                    '' :
                    '#tab_active+' + tab.id;
                µb.openNewTab({
                    url: 'logger-ui.html' + hash,
                    select: true,
                    index: -1
                });
            });
            break;
        default:
            break;
        }
    });
})();

/******************************************************************************/

From https://github.com/gorhill/uBlock/blob/7ae68c8d7db188bc6f20e61fc0172297ceb32eeb/src/js/messaging.js#L919:

// Shortcuts pane

let getShortcuts = function(callback) {
    if ( µb.canUseShortcuts === false ) {
        return callback([]);
    }

    vAPI.commands.getAll(commands => {
        let response = [];
        for ( let command of commands ) {
            let desc = command.description;
            let match = /^__MSG_(.+?)__$/.exec(desc);
            if ( match !== null ) {
                desc = vAPI.i18n(match[1]);
            }
            if ( desc === '' ) { continue; }
            command.description = desc;
            response.push(command);
        }
        callback(response);
    });
};

let setShortcut = function(details) {
    if  ( µb.canUpdateShortcuts === false ) { return; }
    if ( details.shortcut === undefined ) {
        vAPI.commands.reset(details.name);
        µb.commandShortcuts.delete(details.name);
    } else {
        vAPI.commands.update({ name: details.name, shortcut: details.shortcut });
        µb.commandShortcuts.set(details.name, details.shortcut);
    }
    vAPI.storage.set({ commandShortcuts: Array.from(µb.commandShortcuts) });
};

@jbeich
Copy link
Contributor

jbeich commented Jul 28, 2018

For Mozilla bug 1421811, https://github.com/MrAlex94/Waterfox/search?q=1421811&unscoped_q=1421811&type=Commits finds three commits, all tagged 56.2.0.

@MrAlex94 grafted all commits between Firefox 56 and Firefox 60 just before Waterfox 56.2.0, see #553 (comment). Most of the merged commits do nothing in Waterfox. What has actually changed can only be seen by diffing pre- vs. post- merge commits.

@grahamperrin
Copy link

@jbeich thanks! #553 was memorable but before today, I didn't realise the significance of the approach.

@fabeit
Copy link

fabeit commented Aug 30, 2019

So there are still not keyboard shortcuts for Waterfox?

@grahamperrin
Copy link

… keyboard shortcuts for Waterfox?

In Waterfox alpha:

  1. about:addons
  2. menu
  3. manage extension shortcuts

@fabeit
Copy link

fabeit commented Aug 31, 2019

@graham thanks, I don't have alpha, I guess I will wait until the current alpha becomes the stable version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants