General :  K-Meleon Forum
General discussion about K-Meleon. 
highlight all
Posted by: disrupted
Date: September 03, 2009 01:15AM

http://kmext.sourceforge.net/macros/highlighter.7z

based on jsnj's search xtra javascript, this enables selecting a text or phrase and highlighting all similar..this can be useful when searching for specific terms on a website and don't want to fire the find dialog



# K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)

# ---------- highlighter ------js code by jsnj--------------------

_Highlighttext{
setclipboard("");
id(ID_EDIT_COPY);
$highlighted=getclipboard();
open("javascript: (function(){var count=0, text, dv;text=%22".$highlighted."%22;if(text==null)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=%22#A3E897%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&& dv.getComputedStyle(node, null).getPropertyValue(%22display%22)!=%22none%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;})();");
}

highlighter_BuildMenu{
setmenu(Selection,inline,highlighter,5);
setmenu(highlighter,macro,"Highlight All",_Highlighttext);
}

$OnInit=$OnInit."highlighter_BuildMenu;";
# ------------------------------------------------
$macroModules=$macroModules."texthighlighter;";

special thanks to jsnj

Options: ReplyQuote
Re: highlight all
Posted by: jsnj
Date: September 03, 2009 03:45AM

Quote
disrupted
js code by jsnj

Thanks but can't take credit for the JS code. That's from an old forum post from someone years ago that I had lying around. I'm pretty much clueless in JS. smiling smiley

BTW, you can avoid messing with the clipboard by just using the global variable $SelectedText. Resetting the clipboard doesn't always work. Like in the case of copied images for example.

Also, I couldn't get injectJS to work on this one. Hence the macro'd JS toggle dance smiling smiley for users who block JS.

Options: ReplyQuote
Re: highlight all
Posted by: disrupted
Date: September 03, 2009 04:18AM

thanks jsnj, i always forget about enabling it in case user has it disabled.. i hate js

i made an update with additional 2 lines
$_jscurrent=getpref(BOOL,$pref_JavaScript);
setpref(BOOL,$pref_JavaScript, true);


Options: ReplyQuote
Re: highlight all
Posted by: jsnj
Date: September 03, 2009 07:23AM

disrupted, use this one since it doesn't erase the users clipboard nor require them to re-block JS every time they use highlight all.

Attachments: highlighttext.kmm (1.8 KB)  
Options: ReplyQuote
Re: highlight all
Posted by: disrupted
Date: September 03, 2009 07:30AM

cheers smiling smiley i've uploaded updated macro

Options: ReplyQuote
Re: highlight all
Posted by: foobarly
Date: September 03, 2009 04:53PM

Quote
disrupted
cheers smiling smiley i've uploaded updated macro

I love what you do, dear disrupted, but give us a link or GTFO. >:-)

BTW, what's with the faded Mitsubishi logo?

--- sig ---




Edited 1 time(s). Last edit at 09/03/2009 04:54PM by foobarly.

Options: ReplyQuote
Re: highlight all
Posted by: panzer
Date: September 03, 2009 05:36PM

He was either conceived or born in car, made by Mitshubishi. grinning smileygrinning smileygrinning smiley



Edited 1 time(s). Last edit at 09/03/2009 05:36PM by panzer.

Options: ReplyQuote
Re: highlight all
Posted by: disrupted
Date: September 04, 2009 01:04AM

i don't think so..though not unlikely since pops did own a galant at the time grinning smiley

atleast i'm not that crazy:




jsnj updated macro is in above link, it's the same as one attached in forum..only keeping the macros folder structure to make it easy to convert the extensions once we start using alain's extension manager

Options: ReplyQuote
Re: highlight all
Posted by: desga2
Date: September 07, 2009 03:09AM

@ disrupted:
Remember ever you use the clipboard you must restore his old value.

Is very annoying to users lost his clipboard datas.

K-Meleon in Spanish

Options: ReplyQuote
Re: highlight all
Posted by: disrupted
Date: September 07, 2009 03:37AM

why?they can copy again tongue sticking out smiley
ok..i'll do that in the future

(hate you desga)

Options: ReplyQuote
Re: highlight all
Posted by: panzer
Date: August 12, 2011 03:35PM

Is there any way for a making a macro that will higlight all capital letters on the page (not just at the beggining of the sentence, but at names, surnames, names of the books, movies, etc.)?



Edited 1 time(s). Last edit at 08/12/2011 03:35PM by panzer.

Options: ReplyQuote


K-Meleon forum is powered by Phorum.