bookmarks.html bloated with binary favicon data

Discussion of general topics about Mozilla Firefox
User avatar
the-edmeister
Posts: 32249
Joined: February 25th, 2003, 12:51 am
Location: Chicago, IL, USA

Post by the-edmeister »

One more bookmarklet that dickvl did up for me to strip the (Properties) Description from all the bookmarks in a bookmarks.html file.

Code: Select all

javascript:var e=document.getElementsByTagName('dd');el=e.length; for(var i=el-1;i>=0;i--) e[i].parentNode.removeChild(e[i]); alert(el); void 0;
That 2.5 Mb bookmarks.html file is now down to 105 Kb for use as a "local" bookmarks webpage. It loads in a browser window faster than the blue progress bar can be displayed.

Ed
A mind is a terrible thing to waste. Mine has wandered off and I'm out looking for it.
User avatar
RNiK
Posts: 561
Joined: August 9th, 2006, 6:47 am
Location: Forette City, Italy
Contact:

Post by RNiK »

the-edmeister wrote:One more bookmarklet that dickvl did up for me to strip the (Properties) Description from all the bookmarks in a bookmarks.html file.

Code: Select all

javascript:var e=document.getElementsByTagName('dd');el=e.length; for(var i=el-1;i>=0;i--) e[i].parentNode.removeChild(e[i]); alert(el); void 0;
That 2.5 Mb bookmarks.html file is now down to 105 Kb for use as a "local" bookmarks webpage. It loads in a browser window faster than the blue progress bar can be displayed.

Ed

Do I have to use only this bookmaklet or I have to use all the 3 bookmarklet in this thread to clean my bookmark.html??

THANKS!
MondoWin ==> Italian site for information about MS Windows tweaking
User avatar
the-edmeister
Posts: 32249
Joined: February 25th, 2003, 12:51 am
Location: Chicago, IL, USA

Post by the-edmeister »

You need to run both of the scripts that I posted (neither of which are "mine") to completely clean up a bookmarks.html file; the code that dickvl posted on 01/10/2008 is the same as the first one I posted on 4/10/2007.

The main reason that I updated this old thread with that script is that long descriptions for bookmarks was a new feature in Firefox 2.0 (11/06) and not that many websites that I added bookmarks for used long descriptions a year ago. That has become more & more of a 'pain' for me since then and I decided to come up with a fix, with dickvl's help.


Ed
A mind is a terrible thing to waste. Mine has wandered off and I'm out looking for it.
User avatar
RNiK
Posts: 561
Joined: August 9th, 2006, 6:47 am
Location: Forette City, Italy
Contact:

Post by RNiK »

OK! Thanks a lot!
MondoWin ==> Italian site for information about MS Windows tweaking
User avatar
the-edmeister
Posts: 32249
Joined: February 25th, 2003, 12:51 am
Location: Chicago, IL, USA

Post by the-edmeister »

You're welcome.


Ed
A mind is a terrible thing to waste. Mine has wandered off and I'm out looking for it.
User avatar
dickvl
Posts: 54145
Joined: July 18th, 2005, 3:25 am

Post by dickvl »

Of course you can put the code in one bookmarklet:

Code: Select all

javascript:(function(){var a='ID,ICON,ICON_URI,LAST_CHARSET,LAST_MODIFIED,LAST_VISIT,ADD_DATE,PERSONAL_TOOLBAR_FOLDER,SHORTCUTURL,WEB_PANEL',A; var d=document,e=d.getElementsByTagName('*'),E,L,i,j,k=0; a=a.split(','); for(i=0;E=e[i];i++){for(j=0;A=a[j];j++){E.removeAttribute(A);}; if(E.nodeName=='A'){k++}} e=d.getElementsByTagName('DD'); L=e.length; for(i=L-1;i>=0;i--){e[i].parentNode.removeChild(e[i]);} alert('Cleanup Complete - Save as Web Page, Complete\n\nbookmarks: '+k+'\ndescriptions: '+L)})();


A more flexible version that allows to set what to remove in case you want to keep some attributes and the descriptions:

Code: Select all

javascript:(function(){var a='ID,ICON,ICON_URI,LAST_CHARSET,LAST_MODIFIED,LAST_VISIT,ADD_DATE,PERSONAL_TOOLBAR_FOLDER,SHORTCUTURL,WEB_PANEL',A; var d=document,e=d.getElementsByTagName('*'),E,i,j,k=0,L=0; if(a=prompt(a.split(',').join('\n'),a)){a=a.split(','); for(i=0;E=e[i];i++){for(j=0;A=a[j];j++){E.removeAttribute(A)}; if(E.nodeName=='A'){k++}}} e=d.getElementsByTagName('DD'); if((L=e.length)&&(confirm('Remove '+L+' description(s)?'))){for(i=L-1;i>=0;i--){e[i].parentNode.removeChild(e[i])}}else{L=0} alert('Cleanup Complete - Save as Web Page, Complete\n\n'+k+' bookmarks\n'+L+' descriptions ')})();


Another bookmarklet to only remove ICON data ( viewtopic.php?p=2417100#2417100 ):

Code: Select all

javascript:(function(){ var ls=document.getElementsByTagName('*'),lsL=ls.length; for (var i=0; i<lsL; i++) {l=ls[i]; l.removeAttribute('icon'); } alert('Cleanup Complete - Save as Web Page, Complete')})();


A bookmarklet to decode the dates:

Code: Select all

javascript:(function(){var n='ADD_DATE,LAST_MODIFIED'.split(','),D=new Date(),N,V,i,j,k=0,l=document.links,L,M;for(i=0;L=l[i];i++){M=0;for(j=0;N=n[j];j++){if(V=L.getAttribute(N))D.setTime(parseInt(V+'000'));L.setAttribute(N,D.toLocaleString());M=1}if(M)k++}if(k){alert(k)}})();
Last edited by dickvl on July 9th, 2011, 2:37 am, edited 12 times in total.
User avatar
Euchre
Posts: 2804
Joined: April 16th, 2006, 12:48 pm

Post by Euchre »

This is spectacular and does what I've wanted to do with my bookmarks file for a while. I've been doing this more manually, which is very tedious. This makes the operation of preparing my bookmarks file for cross-browser deployment (and storage online) far easier.

One more thing would perfect it for me: If it could automatically save the stripped file to a given path. I don't know JS, so I'm not sure how I could do that.
Gecko
One Rendering Engine to rule them all.
largie
Posts: 113
Joined: March 18th, 2004, 4:13 am
Location: maribor, slovenia

Post by largie »

the latest all-in-one bookmarklet cleans a little more than I would want. not only all the excess data, but also bookmarks and some folders from the very first level disappeared. my bookmarks toolbar was empty too, although the folder was there in the menu. i should add that I tried this on the original never cleaned before bookmarks.html, that was created somewhere in the beginning of 2001 with mozilla 0.9x
User avatar
Euchre
Posts: 2804
Joined: April 16th, 2006, 12:48 pm

Post by Euchre »

largie wrote:the latest all-in-one bookmarklet cleans a little more than I would want. not only all the excess data, but also bookmarks and some folders from the very first level disappeared. my bookmarks toolbar was empty too, although the folder was there in the menu.

As noted in the first page of this thread in this post you need to remove certain lines from the javascript to change what is stripped. The latest version shown just above is thorough and radical, better suited to exporting to an online storage or as a portable file to load as a page when travelling. If you understand the instructions in the linked post, you should be able to use the latest version of the javascript and remove the parts to suit your needs.

So uh, anyone know the JS to write an html file to a given path?
I'd really love to automatically save the results of the stripping.
Gecko
One Rendering Engine to rule them all.
User avatar
dickvl
Posts: 54145
Joined: July 18th, 2005, 3:25 am

Post by dickvl »

Folders should not disappear after using the bookmarklet.
It could that there is data in the file that causes Firefox to skip some bookmarks.

Do you still have all the bookmarks if you save that file another time in Firefox after you opened it or use "Edit > Select All" and Paste the content in a text editor to save the text to another file?
User avatar
RNiK
Posts: 561
Joined: August 9th, 2006, 6:47 am
Location: Forette City, Italy
Contact:

Post by RNiK »

UHMMM... maybe I'm doing something wrong. :(

Here you can see my original Bookmars. Here you can see my cleaned Bookmarks. As you can see all bookmarks under "Bookmarks Toolbar Folder" - "Firefox & Mozilla Information" - "Quick Searches" - "Naruto" - "P2P" - "Varie" disappeared! :shock:

I've used the last bookmarklet posted by dickvl removing this line:

Code: Select all

l.removeAttribute('personal_toolbar_folder');

Any ideas??
MondoWin ==> Italian site for information about MS Windows tweaking
User avatar
RNiK
Posts: 561
Joined: August 9th, 2006, 6:47 am
Location: Forette City, Italy
Contact:

Post by RNiK »

UP! No one?? :?:
MondoWin ==> Italian site for information about MS Windows tweaking
User avatar
dickvl
Posts: 54145
Joined: July 18th, 2005, 3:25 am

Post by dickvl »

If you use the 'Import' item in the Bookmarks Manager then removing the 'personal_toolbar_folder' attribute should not have ill side effects as you already have a Bookmarks Toolbar folder and you can't have two of them and Firefox probably ignore a second BTF if one already exists.
It is probably not a good idea to put such a file in the Firefox profile folder as a replacement for a not working file bookmarks.html.
zep
Posts: 2
Joined: June 17th, 2004, 8:42 pm

Re: bookmarks.html bloated with binary favicon data

Post by zep »

Hello,
I know this is a somewhat old thread, but it matches my problem exactly.
Should this bookmarklet also work on a Firefox3 exported bookmarks.html file? I tried it and it seemed to work, but when I looked at the file, there didn't appear to be any changes.

This database version of bookmarks that FF3 has adopted is the worst thing they did! I consider it a bug and it makes using the browser more difficult. Is there a way to force it use bookmarks.html instead? If not I think I'll have to go back to FF2.

zep
User avatar
steviex
Moderator
Posts: 28902
Joined: August 12th, 2006, 8:27 am
Location: Middle England

Re: bookmarks.html bloated with binary favicon data

Post by steviex »

places.sqlite is here to stay.... I think ALL storage is being moved to sqlite eventually...

Firefox 3 uses sqlite for Bookmarks/History, Search Engines, Cookies, Permission, Downloads, Form History, Content Preferences, Antiphishing and Malware, and DOM Storage

If you want a Browser with the Old Bookmarking, then there is nothing stopping you from Building one. Mozilla won't be doing this.

Also Places is currently being enhanced in the nightlies... They are attempting to land improvements...
Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. -Albert Einstein

Please DO NOT PM me for support... Lets keep it on the board, so we can all learn.
Locked