Sign up | Lost password? | Help

[ advanced search ]

Monday, 29. May 2006, 13:54:36

View selection source

Hello,

I have another User JS :smile: It's similar to Mozilla's function with this name. Here are screen-shots:

http://www.webkitchen.cz/lab/opera/get-selection-source1.png (76 KB)
http://www.webkitchen.cz/lab/opera/get-selection-source2.png (66 KB)

Script is here:

http://www.webkitchen.cz/lab/opera/get-selection-source.js

I recommend add this entry to "Hotclick Popup Menu" in your menu settings.

Item, "View selection source"="Go to page, "javascript:opera.getSelectionSource()""


You can choose from 3 color schemes and easily write your own one. It works only with 9TP1+ because it uses window.getSelection().

Thursday, 6. July 2006, 20:31:50

shoust

avatar

Operaised

Posts: 3009

United Kingdom

Nice, is it possible you could make it a pure bookmarklet? And highlight the selected text parts in yellow if possible?

Saturday, 15. July 2006, 01:43:04

Nice, is it possible you could make it a pure bookmarklet?



Of course, but after I finish it, there is still one minor bug (see TODO in source).

And highlight the selected text parts in yellow if possible?



Now it's updated, what's new?

  • in opened window is selected the same text
  • works in XML pages
  • works correctly in nested frames
  • highlights CDATA


Actual screenshot (I like the desert scheme :smile:)
http://www.webkitchen.cz/lab/opera/get-selection-source-0.5.png (66 KB)

Download version 0.5:
http://www.webkitchen.cz/lab/opera/get-selection-source.js

Friday, 1. September 2006, 15:19:02

Nexus009

avatar

Vagabondo Dell'Infinito

Posts: 1645

Nuova Atlantide -Italy-

@jkb
you can created an userJS with 'word density' function of mozilla FF?
Thanks !

Excuse for my bad Englesh...

Saturday, 16. September 2006, 14:03:29

Nexus009

avatar

Vagabondo Dell'Infinito

Posts: 1645

Nuova Atlantide -Italy-

@jkb
I have tranlate the use of your good script for user on Italian Community :yes:
http://www.operazone.it/forum/viewtopic.php?p=3366#3366

Friday, 29. September 2006, 07:17:34

intravenous

avatar

Posts: 1

Great! Thanks a lot, jkb! it's one of the several features i was missing in opera - view selection source.
do you have paypal account for donations? :wink:

Saturday, 30. September 2006, 04:18:42

alexas

avatar

Posts: 17

Good stuff. Thanks for share

Wednesday, 4. October 2006, 08:36:07

alexas

avatar

Posts: 17

Wish it also could work with images.

Thursday, 5. October 2006, 23:09:27

Nexus009:
I have tranlate the use of your good script for user on Italian Community



Thank you :smile:

intravenous:
Great! Thanks a lot, jkb! it's one of the several features i was missing in opera - view selection source.
do you have paypal account for donations? :wink:



Damn I haven't! :D


alexas:
Wish it also could work with images.



I don't know what you mean, can you explain it, please?


I added there support for word wrap (white-space: pre-wrap). Default is it off, you can toggle it via 'v' key. The shortcut is configurable (toggleWrapKeyCode option).

Version 0.6

Sunday, 8. October 2006, 02:11:31

fantastxue

avatar

微笑的撒旦

Posts: 880

Great! I like it, thanks!

Saturday, 14. October 2006, 00:55:59

shoust:
Nice, is it possible you could make it a pure bookmarklet?



Bookmarklet version is ready:

http://www.webkitchen.cz/lab/opera/get-selection-source-bookmarklet.js.txt

Saturday, 14. October 2006, 08:25:38

HaJotKE

avatar

Grumbling Hyper-Critical Cantankerous Curmudgeon!

Banned User

Germany

Originally posted by jkb:

Bookmarklet version is ready:

It's always crashing my browser... :frown:
Just select the quoted text part of your post above and try it: exception error crash is following! Always.

Saturday, 14. October 2006, 08:30:46

xErath

avatar

javascript guru

Posts: 6401

Norway

Opera Software

Originally posted by HaJotKE:

Just select the quoted text part of your post above and try it: exception error crash is following! Always.


Use memguard and inspectr and report bug please !

Saturday, 14. October 2006, 09:34:33

HaJotKE

avatar

Grumbling Hyper-Critical Cantankerous Curmudgeon!

Banned User

Germany

@xErath:
Thanks. Will do...
Does it work for you?

Saturday, 14. October 2006, 11:11:10

HaJotKE:


Which version of Opera do you have? Requirement is to have at least version 9TP1.


Here is version for direct use in Opera's menu:

http://www.webkitchen.cz/lab/opera/get-selection-source-menu-item.js.txt

Saturday, 14. October 2006, 12:03:16

HaJotKE

avatar

Grumbling Hyper-Critical Cantankerous Curmudgeon!

Banned User

Germany

Originally posted by jkb:

Which version of Opera do you have? Requirement is to have at least version 9TP1.

See my sig... :D OPERA V9.02 build 8585!

I tried also your user.js versions 0.5 and 0.6, with the 'Hotlick popup menu' entry, and I managed to see it once, the next time it crashed again, both with v0.5.

I made a screenshot from the crash, unfortunately I didn't make one from the successful try.
But what I've seen there was an illegal character in the title, illegal because it had been replaced by some 'BlackSpace' placeholder, it replaced the character 'e' in the last word 'source'...

Funny to see also, the title of the display (console) pop-up window is changed to the title of the page with the selected text one is evaluating. M/B this is a hint.
See here:
View Selection Source Crash

Saturday, 14. October 2006, 13:25:25 (edited)

HaJotKE

avatar

Grumbling Hyper-Critical Cantankerous Curmudgeon!

Banned User

Germany

Hi *jkb*, thanks for answering!

I finally succeeded to make it work, there must be a problem with other user.js files I am using.
I removed all of them and now 'get-selection-source.js' being the only one left is working fine. Also the menu item version from your last post is behaving well... :D

Proof:
View Selection Source with Bookmarklet Version
View Selection Source with Menu Item Version

When I get some more time I will dig further into it, M/B.

The list of my user.js I have on, normally:
add-alt-text.js
autosizer.js
highlighter.js
link-alert.js
noclicktoactivate.js
operapedia.js
robosticky.js
vfpO8.js
xml-tree.user.js
just in case you would like trying to reproduce it.

To make it somewhat easier for you I zipped them altogether into:
My 'user.js' files
Plus your version 0.6 for sure. :smile:

Thanks a lot for your good work! :up:

Saturday, 14. October 2006, 14:23:30 (edited)

philry4n

avatar

suspecting victim

Posts: 4660

Indonesia

i can't make it work, i'm using the menu item version, when i click the popup item it doesn't do anything

Saturday, 14. October 2006, 15:25:12

HaJotKE

avatar

Grumbling Hyper-Critical Cantankerous Curmudgeon!

Banned User

Germany

Originally posted by philry4n:

when i click the popup item it doesn't do anything

the menu item needs no clicking of a popup item whatsoever...

Just choose the menu entry after you have selected some parts of contents from the actual page, for sure.
See my screenshots!

BTW, did you observe my remarks about the user.js problematics?

Sunday, 15. October 2006, 05:06:49

saito

avatar

Posts: 300

Japan

Opera Software

Wonderful user.js! But with it, at GMail my Opera 9.02 both Windows and Linux are often aborted repeatedly, when I rolled a mouse wheel.
Renamed .js, that's no problem at GMail. I was using version 0.6

Monday, 16. October 2006, 09:08:49

philry4n

avatar

suspecting victim

Posts: 4660

Indonesia

haven't tried emptying my js, i will do it soon.

Monday, 16. October 2006, 09:29:02

HaJotKE

avatar

Grumbling Hyper-Critical Cantankerous Curmudgeon!

Banned User

Germany

Originally posted by saito:

Renamed .js

What do you mean with renamed?
AFAIK the name of a user.js is irrelevant, it's included into OPERA's workspace if it only exists in OPERA's user.js directory to which OPERA is set.

Please correct me if I'm wrong.

Thursday, 19. October 2006, 01:22:52

saito

avatar

Posts: 300

Japan

Opera Software

Originally posted by HaJotKE:

Originally posted by saito:

Renamed .js

What do you mean with renamed?
AFAIK the name of a user.js is irrelevant, it's included into OPERA's workspace if it only exists in OPERA's user.js directory to which OPERA is set.



I had a trouble at GMail, so temporarily rename this.js to this.jsBAK, to disable it.

As for GMail issue, after disabling view_selection_source, still I have random abortion of Opera, so I think this script might not be guilty. Google sometimes changes their codes without notices, though I don't know if this is the case or not. Some of my friends Opera users don't have any troubles at GMail, but I can't separate the real cause of trouble, for it's a mass of scripts.

Thursday, 19. October 2006, 16:24:32

HaJotKE

avatar

Grumbling Hyper-Critical Cantankerous Curmudgeon!

Banned User

Germany

Originally posted by saito:

temporarily rename this.js to this.jsBAK, to disable it

OK, now I understand, I normally move the file into a "_temp-disabled" folder, which has the same effect as your changing the extension... :D

Friday, 20. October 2006, 06:55:11

philry4n

avatar

suspecting victim

Posts: 4660

Indonesia

how to use the bookmarklet version? step by step instruction please, i'm a newbie in customizing :smile:

Friday, 20. October 2006, 16:01:45

philry4n

avatar

suspecting victim

Posts: 4660

Indonesia

i mean how to implement this userjs, i've already download it to my userjs folder, bookmarked it, now what? :frown:

Friday, 20. October 2006, 16:26:28

HaJotKE

avatar

Grumbling Hyper-Critical Cantankerous Curmudgeon!

Banned User

Germany

You should read the introduction to bookmarklets... (#1)! :frown:

You mustn't download this as a user.js, it has to be copied into the address field of the address bar of your bookmark, that's why it's called a 'bookmarklet', and then calling this bookmark activates said Javascript bookmarklet for your active page!

And don't put it into your user.js folder, this can lead to some unexpected behavior of OPERA!
Bookmarklets are only appearing in the address fields of bookmarks.

Friday, 20. October 2006, 16:36:59

Originally posted by philry4n:

i mean how to implement this userjs, i've already download it to my userjs folder, bookmarked it, now what?




There are three ways how to use it:

  1. UserJS called from menu

    Download the UserJS file into your UserJS directory. Open your ini file with menus definition and find section '[Hotclick Popup Menu]'. Append there this item:

    Item, "View selection source"="Go to page, "javascript:opera.getSelectionSource()""


    Finally this section will looks similar to this:

    [Hotclick Popup Menu] 
    Item, 50872=Copy 
    Item, 67652=Copy to note 
    Feature Voice, Item, 70494=Speak selection 
    Platform Mac, Item, 70494=Speak selection 
    --------------------1 
    Item, 65184=Hotclick search, 200 
    ;Submenu, 291920, Search with menu 
    Submenu, 291920, Internal Search With 
    Item, 65187=Hotclick search, 50 
    Item, 65188=Hotclick search, 51 
    --------------------2 
    Submenu, 291960, Translate menu 
    ;Item, 65186=Hotclick search, 52 
    --------------------3 
    Item, 67394=Go to page, "%t" 
    Item, 65218=Send text in mail. 
    --------------------4 
    Item, "View selection source"="Go to page, "javascript:opera.getSelectionSource()""


    The result is that you can choose a color scheme of the source display (you must edit the JS file) and some other things. Usage will be the same like in Firefox.


  2. Bookmarklet in menu definition

    This is very similar to the previous variant, but you don't need the JS file, just add whole code to the menu ini file. Here is prepared item for usage in the menu:
    http://www.webkitchen.cz/lab/opera/get-selection-source-menu-item.js.txt


  3. Classical bookmarklet

    The simplest way. You just create new bookmark and in the 'Address field' insert the whole JS code [screenshot]. When you want to use it, click on the bookmark item in Opera's 'Bookmarks' panel. The code for this usage is here:
    http://www.webkitchen.cz/lab/opera/get-selection-source-bookmarklet.js.txt



// sorry for my bad English

Friday, 20. October 2006, 17:04:00

philry4n

avatar

suspecting victim

Posts: 4660

Indonesia

Originally posted by HaJotKE:

You should read the introduction to bookmarklets... (#1)!


i've read it and i don't get it, sorry

@jkb :yes: thanks, just tried the bookmarklet on the newest weekly 8629 :smile:

Thursday, 9. November 2006, 09:29:51

pih poh

avatar

Posts: 1

Great work! I really needed this!
But how about copy selection source? Can it be done?

Thursday, 9. November 2006, 10:23:30

HaJotKE

avatar

Grumbling Hyper-Critical Cantankerous Curmudgeon!

Banned User

Germany

Originally posted by pih poh:

But how about copy selection source? Can it be done?

What I do in such a case is: printing it!
I have an 'Adobe Writer' printer driver installed - still version 4 only, alas! Would love to have V5/6/7? - and printing to it gives just clean and neat web - snippets!
W/O images however, which are not included in 'get-selection-source'...

Tuesday, 21. November 2006, 20:48:32

This is very useful and perhaps worthy of inclusion on Opera Developer Community (http://dev.opera.com/articles/opera/)

Although, with your instructions above, you might like to suggest what to do if the user doesn't have a "menu definition" specified. I know I don't have a path specified on both my home and work PC.

Wednesday, 22. November 2006, 04:50:53

Darken

avatar

Dragonfly rulez!

Posts: 356

Canada

Originally posted by jkb:

Script is here: http://www.webkitchen.cz/lab/opera/get-selection-source.jsI recommend add this entry to "Hotclick Popup Menu" in your menu settings.Item, "View selection source"="Go to page, "javascript:opera.getSelectionSource()""


Thanx for this script, installed on latest weekly build and all seems to works fine. :up:

Sunday, 26. November 2006, 15:12:59

piotr_konieczn

avatar

Posts: 72

That's great! :-)

Cheers!

Friday, 8. December 2006, 17:58:02

Originally posted by drworm:


Although, with your instructions above, you might like to suggest what to do if the user doesn't have a "menu definition" specified. I know I don't have a path specified on both my home and work PC.



I created web page with instructions, hope it helps:

http://www.webkitchen.cz/lab/opera/view-selection-source/

Saturday, 3. November 2007, 17:58:44

alexs

avatar

Posts: 776

Austria

Site with script is down?

Sunday, 4. November 2007, 23:06:20

If it was down, it's up now.

I'm curious, is it possible that a variation of this script could be created to copy the source to the clipboard (rather than just viewing it). Some software, such as Evernote, take advantage the HTML information when copying content from a webpage, but Opera is the only browser (I know of) that doesn't allow copying of HTML code. This script might be a useful alternative.

Monday, 5. November 2007, 01:48:54

... also, is it possible to make this a drag-n-drop button? I tried to do this myself but failed :smile:

Monday, 5. November 2007, 19:21:50 (edited)

alexs

avatar

Posts: 776

Austria

Thanks, but i have found the Script and i am write this on my Blog. :smile:

Forums » Opera Community » General Opera topics » User JavaScript