[How To] Auto Expand mail folders using GreaseMonkey

*Edit: Updated for Nextcloud 17 and mail v 0.18.1
Note: if you are using another language besides English you will have to change the text Show all folders and Collapse folders

I was sick of having to expand all my mail folders to avoid this bug:

So I wrote this quick user script to automatically expand all my folders.

Using the Latest Firefox Quantum you will need Violent Monkey addon 2.8.27 ( Latest Violent Mokey no longer works Greasemonkey 4.3 however now works ) or greater, Open the Violent monkey dashboard and click the + sign to add a new script.

Past the following code, changing the yourdomain.tld to your domain:

// ==UserScript==
// @name     Nextcloud Mail Expand folders
// @namespace   https://yourdomain.tld/
// @include     https://yourdomain.tld/apps/mail/*
// @require     https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js
// @require     https://gist.github.com/raw/2625891/waitForKeyElements.js
// @version  1
// @grant    NEXTCLOUDMAIL
// ==/UserScript==

/* Paste Here */

this.$ = this.jQuery = jQuery.noConflict(true);

console.log('[ NMEF ] - Waiting');
waitForKeyElements ("span:contains('Show all folders')", expandALL, true);
waitForKeyElements ("span:contains('Collapse folders')", setTimeout(expandINDIV, 2000), true);

function expandALL() {
  console.log('[ NMEF ] - Expand ALL Folders');
  $("span:contains('Show all folders')")[0].click();

function expandINDIV() {
  console.log('[ NMEF ] - Expand individual Folders');
  $('li[class*="app-navigation-entry--collapsible"] > button').click();

Note: this loads the remote content jquery and waitForKeyElements.js, if you wish to have them bound locally open the // @require links and past the contents at the /* Paste Here */ line. Then just delete the lines:

// @require     https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js
// @require     https://gist.github.com/raw/2625891/waitForKeyElements.js
1 Like

Currently still working well on Firefox 64.0.2 with Nexcloud 15

Updated for Nextcloud 16

Updated for Nextcloud 17