Add all open tabs to favorites

After many iterations, trial and error using chatGPT, I wrote a js script to add all open tabs to favorites.

function OnClick(clickData) {
    var cmd = clickData.func.command;
    var tab = clickData.func.sourcetab;
    var lister = tab.lister;
    var allTabs = lister.tabs;
    var favorites = DOpus.Favorites;
    for (var i = 0; i < allTabs.count; i++) {
        var currentTab = allTabs(i);
        var currentPath = currentTab.path;
        favorites.add(currentPath);
        favorites.save();
    }
}
1 Like

Moving favorites.save(); a line down, so it's done once after the loop finishes instead of once per tab, may speed things up slightly.

Thank you very much for your answer, I will try to continue to improve it

1 Like