阅读:2693回复:4
有没有自动调用搜索引擎搜索并高亮返回的结果集中的关键字的扩展
如题,我希望能自动调用搜索引擎,并在返回的结果集中高亮关键字的扩展,还应当支持中文,
其实在maxthon中有这个功能,不知道firefox中有没有这个扩展? |
|
|
1楼#
发布于:2006-07-17 10:09
|
|
|
2楼#
发布于:2006-07-17 10:09
装了,不过每次都要点击一次才能高亮,不会自动高亮(我已经把自动的选项都选上了)
|
|
|
3楼#
发布于:2006-07-17 10:09
可以试试SearchWP,虽然功能和你要求的有些出入:高亮关键字的不仅是搜索页面,也包括其他页面。但是我是觉得这样挺方便的因为正好可以在搜索打开的网页里面快速定位关键字。
还有Google ToolBar一样的快速关键字定位功能,用了以后几乎就不想要原来的find了。 |
|
4楼#
发布于:2006-07-17 10:09
用个Bookmarklet就行了:
Highlight: javascript:(function(){var count=0, text, dv;text=prompt(%22Search phrase:%22, %22%22);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(%22SPAN%22);spannode.style.backgroundColor=%22yellow%22;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()!=%22SCRIPT%22 && node.tagName.toUpperCase!=%22STYLE%22){for (var child=0; child < node.childNodes.length; ++child){child=child+searchWithinNode(node.childNodes[child], te, len);}}return skip;}window.status=%22Searching for '%22+text+%22'...%22;searchWithinNode(document.body, text.toUpperCase(), text.length);window.status=%22Found %22+count+%22 occurrence%22+(count==1?%22%22:%22s%22)+%22 of '%22+text+%22'.%22;})(); 用正则表达式Highlight: javascript:(function(){var count=0, text, regexp;text=prompt(%22Search regexp:%22, %22%22);if(text==null || text.length==0)return;try{regexp=new RegExp(%22(%22 + text +%22)%22, %22i%22);}catch(er){alert(%22Unable to create regular expression using text '%22+text+%22'.\n\n%22+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(%22SPAN%22);spannode.style.backgroundColor=%22yellow%22;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()!=%22SCRIPT%22 && node.tagName.toUpperCase!=%22STYLE%22){for (var child=0; child < node.childNodes.length; ++child){child=child+searchWithinNode(node.childNodes[child], re);}}return skip;}window.status=%22Searching for %22+regexp+%22...%22;searchWithinNode(document.body, regexp);window.status=%22Found %22+count+%22 match%22+(count==1?%22%22:%22es%22)+%22 for %22+regexp+%22.%22;})(); 也就是没那么自动而已。 |
|
|