Sign up | Lost password? | Help

[ advanced search ]

Go to last post

Sunday, 20. May 2007, 04:27:20

Highlight text

Hi,

Does anyone know if there is a highlight text bookmarklet or userjs available.
Basically what I want is when I select some text on a page I want to
be able to make the text highlighted either by a right click menu entry
or by a button on the toolbar


cheers
blinky

Sunday, 20. May 2007, 12:22:15

AyushJ

avatar

Posts: 4754

Try this:
button

but it is buggy in opera because of the selection bug.



javascript:(function(){ var u=document.createElement("U");u.style="color:green;outline:1px dotted yellow";getSelection().getRangeAt(0).surroundContents(u);getSelection().removeAllRanges()})()

Sunday, 20. May 2007, 13:38:51 (edited)

Hi AyushJ,

Well thanks very much for your reply and button. I find it works quite well.
I wondering if it would be possible to make it highlight the text as in the pic below.

highlight text.jpg

cheers mate
blinky

Sunday, 20. May 2007, 14:03:35

Hi AyushJ,

Thanks mate it now works exactly as I wanted.


cheers

blinky :D

Monday, 21. May 2007, 12:09:52

gorodn

This is a joke, yes?

avatar

Posts: 76

Australia

G'day Ayush.

How would I get this hi-lite to work in v8.5? I've fiddled about, but everything looks as though it's designed for v9+.

Like blinkybill I'll take either a button or context menu. I would really like to get this one, as it appears to duplicate an IE powertoy -- although that wraps the selected text with a <FONT></FONT> colour, which allows saving the page with the highlighting.

Gordon.

Monday, 21. May 2007, 13:10:55

Hi gorodn,

Hi mate...yes its same as the Bayden IEToys which is what
I used for the above pic.
Actually the IEToys in IE7 is very similar to Opera's Hotclick
popup menu.


cheers
blinky

Monday, 21. May 2007, 19:18:30

AyushJ

avatar

Posts: 4754

gorodn: What is the error in Error Console ?

Tuesday, 22. May 2007, 12:25:19

gorodn

This is a joke, yes?

avatar

Posts: 76

Australia

AyushJ -- I created "Highlight.user.js" using the snippet

<function () { var u=document.createElement('U');u.style='text-decoration:none;background-color:#FFFF12';getSelection().getRangeAt(0).surroundContents(u);getSelection().removeAllRanges()}();>

which gives the error:

Unknown thread
Syntax error C:\Program Files\Opera\userjs\Highlight.user.js: line 1 of User JS script :
function () { var u=document.createElement('U');u.style='tex
-----------^

when I start Opera.


blinkybill -- Yah, I found IE Powertoys and Dev-Tools when we had IE5.01. It opened a world of better browsing, I can tell you. I might use Opera for preference, but Micro$oft does indeed have some good stuff amongst all the rubbish!

Gordon.

Tuesday, 22. May 2007, 12:57:22

Hi gorodn,


Off Topic:
Yes I have found them very good programs and even copied
some of their functions into a IE7 skin for Opera I have made.
For me having dial-up, Opera is the only way to go as IE7
is still somewhat slower on a lot of pages I browse.
You should try the latest Opera weekly builds as I generally
find them very stable and usable.

By the way mate where are you in Oz?....Brisbane here :D

cheers
blinky

Wednesday, 23. May 2007, 04:23:43

AyushJ

avatar

Posts: 4754

Here is the UserJS gorodn: HighlightText.js

Button to Highlight the selected text: button

When you press the button, script will highlught the text and save that in Cookie and when you return to the page, script will read the cookie and highlight the text again !

Wednesday, 23. May 2007, 14:58:35

gorodn

This is a joke, yes?

avatar

Posts: 76

Australia

@blinkybill - The other side: I'm a Sandgroper.

@Ayush - OK, I installed the "HighlightText.js", & finally figured out how to install the button :whistle:, but I get the following error in the JS Console:

Highlight text - User JavaScript - Opera Community
http://my.opera.com/community/forums/topic.dml?id=190121
Javascript URL thread: "javascript[:]opera.HighlightText()" [I need to disable a smiley by inserting the []]
Error:
name: ReferenceError
message: Statement on line 35: Reference to undefined variable: getSelection
Backtrace:
Line 35 of User JS script
var sel = getSelection().getRangeAt(0);
Line 1 of unknown script
opera.HighlightText();

Just a quick reminder -- you don't need it I'm sure :smile: -- that I've got v8.5 :cool:

Gordon.

Sunday, 13. July 2008, 08:04:11

Thanks Ayushj,
Just the ticket works a treat, Question: Is there any better way or eadyer way of managing the cookies that the javascrip creates.

Sunday, 13. July 2008, 15:27:34

AyushJ

avatar

Posts: 4754

Originally posted by John164:

Is there any better way or eadyer way of managing the cookies that the javascrip creates.


Tools > Advanced > Cookies... : Quick Find ujs-ayush-hl

Tuesday, 25. November 2008, 10:26:35

gorodn

This is a joke, yes?

avatar

Posts: 76

Australia

G'day AyushJ -

Well, we finally upgraded everything: you-beaut 2.4GHz D845GE chipset in an OEM box, genuine paid-for W2K SP4, aaaannnndd... Opera 9.51 :cheers:

So, then I downloaded your "HighlightText.js" and your button to make it go -- and it does!!!! :yes:

However... :o: Is it possible to remove the underscoring? I had a Cap'n Cook at the js, and soon saw

...
var U=document.createElement("U");
U.style="background-color:#ffff12";
sel.surroundContents(U);
...


but I don't think this really is responsible for the underscore.

I'd like to get rid of the underscore because it adds an emphasis probably not intended by the page author, and can inadvertently mask hyperlinks -- depending on how the author CSS'ed them.

Gordon.

Forums » Opera Community » General Opera topics » User JavaScript