BrowserWorks / Waterfox

The official Waterfox 💧 source code repository
https://www.waterfox.net
Other
3.83k stars 340 forks source link

uBlock keyboard shortcuts panel not visible in Waterfox #704

Closed Rikk closed 3 years ago

Rikk commented 6 years ago

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 commented 6 years ago

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

Rikk commented 6 years ago

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

grahamperrin commented 6 years ago

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 commented 6 years ago

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 https://github.com/MrAlex94/Waterfox/issues/553#issuecomment-388629097. 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 commented 6 years ago

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

fabeit commented 5 years ago

So there are still not keyboard shortcuts for Waterfox?

grahamperrin commented 5 years ago

… keyboard shortcuts for Waterfox?

In Waterfox alpha:

  1. about:addons
  2. menu
  3. manage extension shortcuts
fabeit commented 5 years ago

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