Did you ever wish you could delete all completed items in a Workflowy branch in 2 clicks ?

This can be easily done in your browser using a scriptlet - a javascript code you insert in a browser button instead of a URL.

Thanks to Claude AI, I got the code below, which does exactly that, with a nice addition: it only deletes the visible completed lines in the current page. It means that if a branch somewhere is collapsed (content not visible) it will be ignored.

Here is the code to copy and paste into the URL field of a bookmark:

javascript:(function(){try{if(WF.currentSearchQuery()){alert('Une recherche est active : efface-la d\'abord.');return}
if(!WF.completedVisible()){alert('Les éléments complétés sont masqués : affiche-les d\'abord.');return}
var r=WF.currentItem(),l=[],ex=function(c){return typeof c.isExpanded==='function'&&c.isExpanded()};(function w(p){p.getChildren().forEach(function(c){if(c.isCompleted()){l.push(c)}else if(ex(c)){w(c)}})})(r);if(!l.length){alert('Aucune tâche complétée visible ici.');return}var n=r.isMainDocumentRoot()?%27Accueil%27:(r.getNameInPlainText?r.getNameInPlainText():%27%27);if(!confirm(%27Dans « %27+n+%27 » : supprimer %27+l.length+%27 tâche(s) complétée(s) visible(s), sous-éléments compris ?%27))return;var A=[%27deleteItems%27,%27removeItems%27,%27trashItems%27].filter(function(k){return typeof WF[k]===%27function%27})[0],S=[%27deleteItem%27,%27removeItem%27,%27trashItem%27].filter(function(k){return typeof WF[k]===%27function%27})[0];if(!A&&!S){var k=[];for(var x in WF){if(/del|rem|trash/i.test(x))k.push(x)}alert(%27Aucune fonction de suppression reconnue. Candidates : %27+k.join(%27, %27));return}WF.editGroup(function(){if(A){WF[A](l)}else{l.forEach(function(c){WF[S](c)})}})}
catch(e){alert(%27Erreur : %27+e.message)}})();

Some additional notes:

  1. The above code is minified but I added a few linefeeds in order to let the code be easily copied.
  2. Sorry but the messages are in French.