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

Status Bar broken in 117 #275

Open
rebmcr opened this issue Sep 1, 2023 · 6 comments
Open

Status Bar broken in 117 #275

rebmcr opened this issue Sep 1, 2023 · 6 comments

Comments

@rebmcr
Copy link

rebmcr commented Sep 1, 2023

Using the latest version, last edited 7 months ago. Same with installation folder and chrome folder items. (Windows 10)

@benzBrake
Copy link

try my script(only tested on alice0775's loader): https://github.com/benzBrake/FirefoxCustomize/blob/master/userChromeJS/StatusBar.uc.js

@rebmcr
Copy link
Author

rebmcr commented Sep 4, 2023

try my script(only tested on alice0775's loader): https://github.com/benzBrake/FirefoxCustomize/blob/master/userChromeJS/StatusBar.uc.js

That doesn't seem to work for me either, with either loader, which seems odd.

@LummoxJR
Copy link

LummoxJR commented Sep 4, 2023

This is my current version of the file that's working for me in 118.0b4. I had to make some modifications a while back to the way the script started up, and to the styles. You might want to do a diff between my version and another one and see what changes you want to use.

// ==UserScript==
// @name            Status Bar
// @author          xiaoxiaoflood
// @include         main
// @startup         UC.statusBar.exec(win);
// @shutdown        UC.statusBar.destroy();
// @onlyonce
// ==/UserScript==

const { CustomizableUI, StatusPanel } = window;

UC.statusBar = {
  PREF_ENABLED: 'userChromeJS.statusbar.enabled',
  PREF_STATUSTEXT: 'userChromeJS.statusbar.appendStatusText',

  get enabled() {
    return xPref.get(this.PREF_ENABLED);
  },

  get textInBar() {
    return this.enabled && xPref.get(this.PREF_STATUSTEXT);
  },

  init: function () {
    const { CustomizableUI } = Services.wm.getMostRecentBrowserWindow();
    xPref.set(this.PREF_ENABLED, true, true);
    xPref.set(this.PREF_STATUSTEXT, true, true);
    this.enabledListener = xPref.addListener(this.PREF_ENABLED, (isEnabled) => {
      CustomizableUI.getWidget('status-dummybar').instances.forEach(dummyBar => {
        dummyBar.node.setAttribute('collapsed', !isEnabled);
      });
    });
    this.textListener = xPref.addListener(this.PREF_STATUSTEXT, (isEnabled) => {
      if (!UC.statusBar.enabled)
        return;

      _uc.windows((doc, win) => {
        let StatusPanel = win.StatusPanel;
        if (isEnabled)
          win.statusbar.textNode.appendChild(StatusPanel._labelElement);
        else
          StatusPanel.panel.appendChild(StatusPanel._labelElement);
      });
    });

    this.setStyle();
    _uc.sss.loadAndRegisterSheet(this.STYLE.url, this.STYLE.type);

    CustomizableUI.registerArea('status-bar', {});

    Services.obs.addObserver(this, 'browser-delayed-startup-finished');
  },

  exec: function (win) {
    let document = win.document;
    let StatusPanel = win.StatusPanel;

    let dummystatusbar = _uc.createElement(document, 'toolbar', {
      id: 'status-dummybar',
      toolbarname: 'Status Bar',
      hidden: 'true'
    });
    dummystatusbar.collapsed = !this.enabled;
    dummystatusbar.setAttribute = function (att, value) {
      let result = Element.prototype.setAttribute.apply(this, arguments);

      if (att == 'collapsed') {
        let StatusPanel = win.StatusPanel;
        if (value === true) {
          xPref.set(UC.statusBar.PREF_ENABLED, false);
          win.statusbar.node.setAttribute('collapsed', true);
          StatusPanel.panel.appendChild(StatusPanel._labelElement);
          win.statusbar.node.parentNode.collapsed = true;;
        } else {
          xPref.set(UC.statusBar.PREF_ENABLED, true);
          win.statusbar.node.setAttribute('collapsed', false);
          if (UC.statusBar.textInBar)
            win.statusbar.textNode.appendChild(StatusPanel._labelElement);
          win.statusbar.node.parentNode.collapsed = false;
        }
      }

      return result;
    };
    win.gNavToolbox.appendChild(dummystatusbar);

    win.statusbar.node = _uc.createElement(document, 'toolbar', {
      id: 'status-bar',
      customizable: 'true',
      context: 'toolbar-context-menu',
      mode: 'icons'
    });

    win.statusbar.textNode = _uc.createElement(document, 'toolbaritem', {
      id: 'status-text',
      flex: '1',
      width: '100'
    });
    if (this.textInBar)
      win.statusbar.textNode.appendChild(StatusPanel._labelElement);
    win.statusbar.node.appendChild(win.statusbar.textNode);

    win.eval('Object.defineProperty(StatusPanel, "_label", {' + Object.getOwnPropertyDescriptor(StatusPanel, '_label').set.toString().replace(/^set _label/, 'set').replace(/((\s+)this\.panel\.setAttribute\("inactive", "true"\);)/, '$2this._labelElement.value = val;$1') + ', enumerable: true, configurable: true});');

    let bottomBox = document.createElement('vbox');
    win.bottomBox = bottomBox;
    bottomBox.id = 'browser-bottombox';
    bottomBox.append(win.statusbar.node);

    if (!this.enabled)
      bottomBox.collapsed = true;

    document.getElementById('fullscreen-and-pointerlock-wrapper').insertAdjacentElement('afterend', bottomBox);

    win.addEventListener('fullscreen', this.fsEvent);

    if (document.readyState === 'complete')
      this.observe(win);
  },

  observe: function (win) {
    if(!win.bottomBox) this.exec(win);
    CustomizableUI.registerToolbarNode(win.statusbar.node);
    win.bottomBox.appendChild(win.statusbar.node);
    win.statusbar.node.parentNode = bottomBox;
  },

  orig: Object.getOwnPropertyDescriptor(StatusPanel, '_label').set.toString(),

  setStyle: function () {
    this.STYLE = {
      url: Services.io.newURI('data:text/css;charset=UTF-8,' + encodeURIComponent(`
        @-moz-document url('${_uc.BROWSERCHROME}') {
          #status-bar {
            color: initial !important;
            background-color: var(--toolbar-non-lwt-bgcolor) !important;
          }
          #status-text > #statuspanel-label {
            border-top: 0 !important;
            background-color: unset !important;
            color: var(--lwt-text-color) !important;
          }
          #status-bar > #status-text {
            display: flex !important;
            justify-content: center !important;
            align-content: center !important;
            flex-direction: column !important;
          }
        }
      `)),
      type: _uc.sss.USER_SHEET
    }
  },
  
  destroy: function () {
    const { CustomizableUI } = Services.wm.getMostRecentBrowserWindow();

    xPref.removeListener(this.enabledListener);
    xPref.removeListener(this.textListener);
    CustomizableUI.unregisterArea('status-bar');
    _uc.sss.unregisterSheet(this.STYLE.url, this.STYLE.type);
    _uc.windows((doc, win) => {
      const { eval, statusbar, StatusPanel } = win;
      eval('Object.defineProperty(StatusPanel, "_label", {' + this.orig.replace(/^set _label/, 'set') + ', enumerable: true, configurable: true});');
      StatusPanel.panel.appendChild(StatusPanel._labelElement);
      doc.getElementById('status-dummybar').remove();
      statusbar.node.remove();
      win.removeEventListener('fullscreen', this.fsEvent);
    });
    Services.obs.removeObserver(this, 'browser-delayed-startup-finished');
    delete UC.statusBar;
  }
}

UC.statusBar.init();

@DeepMac
Copy link

DeepMac commented Sep 8, 2023

Using the latest version, last edited 7 months ago. Same with installation folder and chrome folder items. (Windows 10)

You need to update some Javascript modules per #265 and then clear your startup cache. No need to update the statusbar script itself.
Tested and verified a bit ago and have my status bar back LIKE GOD INTENDED. ;)

@Lalarian
Copy link

Lalarian commented Sep 11, 2023

Man, the fumbling is becoming worse and worse with each version of Firefox!
They really want to destroy themselves. :(

And even after these changes it doesn't work like it was supposed to at all anymore :(
I actually have two lines, when I am doing a search (ctrl+f).
The added in status bar ist the lowest.
The line with the search one above it.

Also it doesn't apply the skin to the bar anymore.

@rebmcr
Copy link
Author

rebmcr commented Sep 11, 2023

Using the latest version, last edited 7 months ago. Same with installation folder and chrome folder items. (Windows 10)

You need to update some Javascript modules per #265 and then clear your startup cache. No need to update the statusbar script itself. Tested and verified a bit ago and have my status bar back LIKE GOD INTENDED. ;)

Aye, though I needed an extra edit in the end, to config.js

#265 (comment)

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

6 participants
@DeepMac @Lalarian @LummoxJR @benzBrake @rebmcr and others