01-10-2009, 11:20 PM
I found these two scripts which are relevant (as well as some other cool bookmarklets) here:
https://www.squarefree.com/bookmarklets/pagedata.html
There is one that highlights each occurrence of a search phrase (presented through a simple dialog):
The javascript is here:
The other one does the same thing but for regular expressions:
The website says they work only for Mozilla/Firefox or Opera browsers but I thought maybe they can be reverse engineered to work in QM (Toolbar Webbrowser). I haven't had a chance to look at them carefully (I don't know javascript ) but I post them here in case someone wants to take a crack at them.
Good luck...I will post any progress I make as well.
Stuart
https://www.squarefree.com/bookmarklets/pagedata.html
There is one that highlights each occurrence of a search phrase (presented through a simple dialog):
The javascript is here:
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.replaceChild(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 other one does the same thing but for regular expressions:
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.replaceChild(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+".";})();The website says they work only for Mozilla/Firefox or Opera browsers but I thought maybe they can be reverse engineered to work in QM (Toolbar Webbrowser). I haven't had a chance to look at them carefully (I don't know javascript ) but I post them here in case someone wants to take a crack at them.
Good luck...I will post any progress I make as well.
Stuart
