Customize browser tab title?

Right now the title of the browser tab is identical to the title of the note being viewed. Journal/Week/2024-04-22, or SETTINGS, for example. I’d like to add a postfix to the title. Journal/Week/2024-04-22 - SilverBullet, or SETTINGS - SilverBullet.

Is this possible to do? The Space Script feature sounds promising. If I can hook the function that sets the browser title and change the string in-flight, that could work. But I’m a little bit lost trying to find the function I’d need to hook.

My use case is using Hammerspoon to add a hotkey for the SilverBullet browser tab.

This is hacky, but this seems to work:

```space-script
silverbullet.registerEventListener({name: "editor:pageLoaded"}, (event) => {
  const pageName = event.data[0];
  setTimeout(() => {
    document.title = `${pageName} - whatever`;  
  });
});
```
1 Like

@zef the above doesn’t seem to work any longer - if you do it without no or a short timeout, the title gets replaced again with the original (no suffix) title.

For anyone else coming to this now, you need to add a delay of around 500ms on. I’m using 1 second here:

```space-script
silverbullet.registerEventListener({name: "editor:pageLoaded"}, (event) => {
  const pageName = event.data[0];
  setTimeout(() => {
    document.title = `${pageName} - whatever`;  
  }, 1000);
});
```

I’m not sure if it’s because the editor:pageLoaded is no longer the correct/final event to listen for?