How to collapse (toggle) all bookmark folder?
- Drumbrake
- Posts: 1177
- Joined: February 14th, 2011, 2:34 am
How to collapse (toggle) all bookmark folder?
Is there any way -including extensions- to toggle all bookmark folders in the side bar to collapsed and expand them again ?
-
- Posts: 6437
- Joined: February 3rd, 2009, 6:29 pm
Re: How to collapse (toggle) all bookmark folder?
This is what I do.
The code works for extensions that allow you to run javascript with chrome privileges, like PrefBar.
https://addons.mozilla.org/firefox/addon/67148
Code: Select all
// toggle all tree nodes in the bookmarks sidebar
var browser = document.getElementById("sidebar");
var contentDocument = browser.contentDocument;
var tree = contentDocument.getElementById("bookmarks-view");
if (tree) {
var view = tree.view;
if (view.isContainer(0) && !view.isContainerOpen(0)) {
// expand all tree nodes
for (var i = 0; i < view.rowCount; i++) {
if (view.isContainer(i) && !view.isContainerOpen(i)) {
view.toggleOpenState(i);
}
}
} else {
// collapse all tree nodes except Bookmarks Menu folder
for (var i = view.rowCount - 1; i >= 0; i--) {
var name = view.getCellText(i, tree.columns.getColumnAt(0));
if (view.isContainer(i) &&
view.isContainerOpen(i) &&
name != "Bookmarks Menu") {
view.toggleOpenState(i);
}
}
}
} else {
// open bookmarks sidebar
toggleSidebar("viewBookmarksSidebar");
}
The code works for extensions that allow you to run javascript with chrome privileges, like PrefBar.
https://addons.mozilla.org/firefox/addon/67148
- Drumbrake
- Posts: 1177
- Joined: February 14th, 2011, 2:34 am
Re: How to collapse (toggle) all bookmark folder?
Thank you so much,this is yet another useful feature (IMHO) that for who knows what reason has never been considered-if I got it right from your last comment,this won't work as bookmarklet:will it also work (aside of PrefBar) if executed in the Error Console (not a fast way to do this for sure) or with Custom Buttons
https://addons.mozilla.org/en-US/firefox/addon/custom-buttons/ ?
https://addons.mozilla.org/en-US/firefox/addon/custom-buttons/ ?
-
- Posts: 6437
- Joined: February 3rd, 2009, 6:29 pm
Re: How to collapse (toggle) all bookmark folder?
Drumbrake wrote:if executed in the error console
You can run the code in scratchpad in the browser environment.
1. open about:config
2. set devtools.chrome.enabled to true
3. tools > web developer > scratchpad
4. environment > browser
5. edit > paste (i.e. copy and paste code above)
6. execute > run