» Welcome Guest
[ Log In :: Register ]

 

[ Track this topic :: Email this topic :: Print this topic ]

Topic: Bookmarklets get broken on sync, between Opera and Moz< Next Oldest | Next Newest >
Anton
Unregistered





Posted: July 27 2004,14:55

I have (javascript) bookmarklets in Opera, which get broken in Mozilla when they are synchronized; the link is currupted and the title is changed into some javascript. However, the exact same bookmarklets with the exact same titles can be manually created and preserved in Moz, so it's not that Moz can't handle them.

What's worse, even when I have manually synchronized Opera and Moz, running a BMC synch results in *both* new sets of bookmarks getting corrupted: titles and links are ruined in Opera and Moz, despite the original sets containing identical correct data.

I can post the two correct sets of bookmarks if you want to experiment with them.
Back to top
Magnus Brading
Almighty Author



Group: Super Administrators
Posts: 2751
Joined: Aug. 2002
Posted: July 29 2004,21:23

Yes, please post or email example files to me, I will then look into it and try to fix the problem. Thanks.

--------------
Software author and website owner
Back to top
Profile PM WEB 
Anton
Unregistered





Posted: July 30 2004,12:06

Here are two representative examples of bookmarklets that get chewed up when synched from Opera into Mozilla.

Note that I didn't make these bookmarklets; I found them on the web.

The first one I renamed to "Highlight Term" once I had bookmarked it in Opera.

javascript:(function(){var count=0, text, dv;text=prompt("Search phrase:", "");if(text==null || text.length==0)return;dv=document.defaultView;function searchWithinNode(node, te, len){var pos, skip, spannode, middlebit, endbit, middleclone;skip=0;if( node.nodeType==3 ){pos=node.data.toUpperCase().indexOf(te);if(pos>=0){spannode=document.createElement("SPAN");spannode.style.backgroundColor="yellow";middlebit=node.splitText(pos);endbit=middlebit.splitText(len);middleclone=middlebit.cloneNode(true);spannode.appendChild(middleclone);middlebit.parentNode.replaceCh
ild(spannode,middlebit);++count;skip=1;}}else if( node.nodeType==1&& node.childNodes && node.tagName.toUpperCase()!="SCRIPT" && node.tagName.toUpperCase!="STYLE"){for (var child=0; child < node.childNodes.length; ++child){child=child+searchWithinNode(node.childNodes[child], te, len);}}return skip;}window.status="Searching for '"+text+"'...";searchWithinNode(document.body, text.toUpperCase(), text.length);window.status="Found "+count+" occurrence"+(count==1?"":"s")+" of '"+text+"'.";})();

The second one I renamed to "Highlight Regular Expression":

javascript:(function(){var count=0, text, regexp;text=prompt("Search regexp:", "");if(text==null || text.length==0)return;try{regexp=new RegExp("(" + text +")", "i");}catch(er){alert("Unable to create regular expression using text '"+text+"'.\n\n"+er);return;}function searchWithinNode(node, re){var pos, skip, spannode, middlebit, endbit, middleclone;skip=0;if( node.nodeType==3 ){pos=node.data.search(re);if(pos>=0){spannode=document.createElement("SPAN");spannode.style.backgroundColor="yellow";middlebit=node.splitText(pos);endbit=middlebit.splitText(RegExp.$1.length);middleclone=middlebit.cloneNode(true);spannode.appendChild(middleclone);middlebit.parentNode.replaceCh
ild(spannode,middlebit);++count;skip=1;}}else if( node.nodeType==1 && node.childNodes && node.tagName.toUpperCase()!="SCRIPT" && node.tagName.toUpperCase!="STYLE"){for (var child=0; child < node.childNodes.length; ++child){child=child+searchWithinNode(node.childNodes[child], re);}}return skip;}window.status="Searching for "+regexp+"...";searchWithinNode(document.body, regexp);window.status="Found "+count+" match"+(count==1?"":"es")+" for "+regexp+".";})();

Anyway, although I can create and name these exact same bookmarklets manually in both Opera and Mozilla, and they are stable, something goes wrong when they are transformed from one format to the other by BMC. In the version for the browser receiving (as opposed to sourcing) the synch, the title is replaced by a chunk of the javascript, and the functions no longer work, so I guess the content gets truncated or something.
Back to top
Magnus Brading
Almighty Author



Group: Super Administrators
Posts: 2751
Joined: Aug. 2002
Posted: July 30 2004,13:05

Ok, thanks, I have saved them for later analysis. I suspect that the problem is related to the quotes anyway, since they are used as internal data separators in at least Mozilla bookmark files too, and probably have to be escaped somehow.

--------------
Software author and website owner
Back to top
Profile PM WEB 
3 replies since July 27 2004,14:55 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]