← All examples

Action Navigation slack.com

Slack: collapse all sidebar sections

Collapses every expanded section in the channel sidebar with one click for a short, tidy list.

Code to copy

// Collapse every expanded section in the channel sidebar at once
const headings = document.querySelectorAll('.p-channel_sidebar__section_heading[aria-expanded="true"]');
let n = 0;
headings.forEach(function (h) {
  const btn = h.querySelector('.p-channel_sidebar__section_heading_button') || h;
  btn.click();
  n++;
});
console.log('[Slack] collapsed ' + n + ' sidebar sections');

How to use this example

  1. Copy the code with the button above.
  2. Install JustZix (2 minutes) and open the extension on the target page.
  3. Add a new rule matching that page.
  4. Enable the action panel, add a button in the Actions tab and paste the code into it — run it with one click.

Rate this example

No ratings yet — be the first.

Does this example work?

Snippets are useless without somewhere to paste them.

JustZix takes 2 minutes to install and runs your code on every matching page. No account, no payment.

Download free See use cases