VivaldiHooks - more useful mods!



  • Finally made my first Hook!

    Still have a ways to go in my understanding of how it works, but even a small step forward is something.

    @nomadic said in (Help) Button to hide vertical tabbar?:

    Hadden89 luetage There is the option of using VivaldiHooks to trigger inbuilt Vivaldi commands.

    I am far from an expert at writing a hook mod, but looking at panel-right-toggle-button.js and bookmarks-button.js as examples and setting a breakpoint to see the function that was called on toggling the tab bar, I made this:

    //Toggle tab button before AddressBar
    {
      function toggleTabsOnClick() {
        const WindowActions = vivaldi.jdhooks.require("WindowActions");
        WindowActions.toggleTabs(window.vivaldiWindowId);
      }
    
      vivaldi.jdhooks.hookClass("toolbars_Toolbar", (origClass) => {
        const React = vivaldi.jdhooks.require("React");
        const SettingsPaths = vivaldi.jdhooks.require("_PrefKeys");
        const ToolbarButton = vivaldi.jdhooks.require("toolbars_ToolbarButton");
    
        return class extends origClass {
          render() {
            let ret = super.render();
            if (this.props.name == SettingsPaths.kToolbarsNavigation) {
              ret.props.children.push(
                React.createElement(ToolbarButton, {
                  tooltip: "Toggle Tab Bar",
                  onClick: toggleTabsOnClick,
                  image: vivaldi.jdhooks.require("_svg_tabs_large"),
                })
              );
            }
            return ret;
          }
        };
      });
    }
    
    

    There is probably a better way to do it, but if you want a button that toggles the tab bar, this works.

    tabs-toggle.gif



  • VivaldiHooks seems to break new profiles including using a clean --user-data-dir. Just leads to a an empty URL.

    https://github.com/justdanpo/VivaldiHooks/issues/43


Log in to reply
 

Looks like your connection to Vivaldi Forum was lost, please wait while we try to reconnect.