Opera extension: Source
Monday, January 17, 2011 10:22:42 PM
Updated: April 10, 2012 - v1.0.1
The main problems I faced with Opera's default source viewer are:
- it doesn't convert links to click-able links,
- if it has syntax highlighting, then it should be more nicer and preciser, but it is not,
- on standard skin if you search for a string, it's nearly impossible to notice the highlighted text, because it has almost the same color (white) as the background.
Install extension Opera 11.60+
Features
- Viewing page-source with click-able links, text wrapping, line numbers, and since it is an HTML page, the search is same as on any other page (highlighted text on dimmed page)- Viewing selection source
- Syntax highlighting with customizable colors, line numbering, custom shortcuts, text wrap
- Centering content for plain text or NFOs
- View NFO ASCII Arts in browser
- Edit/view the source of the selected element, or element removal with a single click
- HTML/CSS/JavaScript (auto) formatting
- JavaScript compressing
- BBCode/HTML generation from the highlighted code
- and more (details below)...
Disadvantages
Since it uses JavaScript to parse and highlight the code, will be slower than the default viewer. But this depends mainly on two things: the size of the source and the number of DOM nodes. For example, with a 5MB file that has a huge DOM tree, the load time can take be up to 30+ seconds on my (old) machine, and in the same case it uses a lot memory. But the most web-pages aren't that big, so, in most cases it'll work just fine.So, how does it work?
Ctrl+F9 for viewing the page source or the selection source. It works for frames too, first click in the desired frame, and press the mentioned combination. If you are not sure that you are in a frame, or just want to check the top document's source, then press Ctrl+Shift+F9.Since, Ctrl+F9 opens the source of the actual DOM, it may contain unwanted code pieces, for example modifications by other extensions, which is usually unnecessary to see. To filter these unwanted nodes from source, there is input in preferences, where you give an XPath query, and the extension will try remove the matched nodes (only) from the source viewer. It can remove element and attribute nodes, and since it is one XPath query, you have to catenate multiple queries with "|" sign. Here is an example that removes some other extensions' stuff (ExtendTube, Ghostery, AutoPatchWork, WOT, AdBlock, HyperTranslate and the last part which will remove all tags right under the root, which is not the head or the body, example for this is my other extension, Imagus).
/html/head/style[@id="ext-style-general" or @id="ext-page-clean-up" or starts-with(text(), ".ghostery-alert") or @id="AutoPatchWork-style" or contains(text()[position()=3], "WOT Services") or (starts-with(text(), "/*") and contains(text(), "! Fanboy"))] | /html/body/div[@id="wotwarning" or @id="wotwrapper" or (@style and count(@*) = 1 and string-length(@style) > 700 and contains(@style, "z-index: 21474"))] | /html/*[not(self::head) and not(self::body)]Ctrl+Alt+F9 [+Shift works here too] will make an AJAX request to get the original source. You can reload the source viewer, i.e., you don't have to open a new tab for viewing selection source on the same page, instead just select some text on the page, and press F5 in source viewer.
When viewing sources there is a "Go to line" feature also (key G), but only available if you enable line numbering.
Sometimes the highlighter can't determine which language is the opened file, and it will recognize incorrectly or as plain text. It's possible to re-highlight the script by pressing X and entering the (file)extension of the programming language (like js for JavaScript, py for Python).
There is a special use of this feature, when for the extension a "+" (plus sign) is given. In this case it will try to render the whole code as HTML.
To use compression for JavaScript files, press the shortcut (key C, only works on files that were identified or re-highlighted as js), and in the popup type the command-letters from the list.
Pressing F will format HTML, CSS or JavaScript to more readable code. Sometimes there are minified/obfuscated CSS/JavaScript codes in source viewer (Ctrl+F9), and if you don't want to format the whole file, you can select some code on the page (in case of JS/CSS, the surrounding tags needed too) and then press F, which will open a new window with the formatted version only of the selected code. Formatting can be set to be done automatically.
There is possibility to generate BBCode or HTML from the highlighted source. The method is similar like above, select some code in the source, press B, give the output format, which can be "html" or "bb" (before bb you can put a "#" sign to add hash-mark before color values), and press enter.
On web pages, Ctrl+Q will activate the inspecting mode (if you move your mouse, you'll see blue outlines around the elements, where every parent element is outlined), then if you click on one of them, you will be able to edit or view its source (depends on what is the default action; it can be set in preferences).
After you go to the edit mode, then under the textarea each parent node is listed from the target up to the BODY, so you can quickly change your target, and edit its outerHTML property. Shift + click on a tag will open a new tab with the element's source. Ctrl + click on a tag will remove it from DOM.
If you hold Shift along with the previous shortcut (so, Ctrl+Shift+Q), then you'll see green outlines. This indicates that now by clicking on an element will enable it's contenteditable property, and you can modify the content of that element.
To remove an element press Ctrl+Shift+R which will trigger the inspection (red outlines will appear), and clicking on an element will remove it from the DOM. Holding Shift key will allow you to remove more than one node without leaving the inspection (Shift also works in "green" mode). Ctrl + click will remove all nodes that have the same class as the clicked one has, Alt + click removes all nodes with same tag.
Jump between these three modes with Space. Quit from any mode: press again the shortcut, click with right mouse button or press Escape.
When you see some HTML code on a page (e.g., on a random forum someone shared a piece of HTML code), and you want to try out how will it look like in the browser, you can select that text and press Shift+F9, which will open a new page with the rendered HTML code.
You can enable the toolbar button, and reach the functions from there, or there is a simple API that you can use for context menu or for a button. It's window.oexSource(). If you want to put it into the context menu, you have to edit the standard_menu.ini file which is placed in Opera's installation folder. After you created a backup, find this line [Document Popup Menu]. Below this you can see the entries for a document's context-menu. Somewhere here insert a new line with this text:
Item, "View source" = Go to page,"javascript:(window.oexSource||alert)('Not available!')",,,Attachment Documents
Restart Opera, and there you go.However, using these methods doesn't work well in frames, keyboard shortcuts are recommended.
Thanks for the icon: http://esk6a.deviantart.com/
Syntax highlighting is based on google-code-prettify
HTML/CSS/JavaScript formatting/unpacking is powered by jsbeautifier
JavaScript compression is powered by Closure Compiler Service
Translation
You can contribute by translating these files:- lng.js
- options_lng.js
- description.txt
Open the files in a text editor, translate and send them (details in files).
Done: English, Hungarian, Russian (by burn).







1 2 Next »
A.shunshunyi # Thursday, January 20, 2011 8:41:39 AM
lifeh2o # Thursday, January 20, 2011 4:25:00 PM
lifeh2o # Thursday, January 20, 2011 4:28:46 PM
tag in start and end of the selection. try this one http://blog.webkitchen.cz/view-selection-source
Deathamns # Friday, January 21, 2011 9:10:44 PM
Originally posted by lifeh2o:
Maybe it was correct, but not that way as you expected. But OK, my fault, I didn't explain how it works exactly.
If the selection start and the selection end are on the same element, then ONLY the selection (if the selection has other elements, like bold text or link, then those elements too) will be copied and the element's tag (with attributes) will surround it.
If the selection goes through more elements, for example: if you start selecting from a table cell and drag outside from the whole table, and end with in a paragraph element, then the cell, row, (thead, caption if there is), table tags will be added to the beginning and the p close tag to the end of the selection. If you don't understand my poor English maybe this will help: http://img4.imageshack.us/img4/2083/oexsourceselection.jpg
(Actually the 2., 3. and the last examples are buggy, because it's not enclosed by div. And I found some more since I published version 0.7.)
The script that you linked prints out the entire content of the common parent of the elements in selection. E.g., on the linked page select the second header's text ("Try it right now!") and some words from the following paragraph ("To see how"), then compare that solution with mine.
That script will show much more data then I actually need. Mine script will show only the selected text with the necessary HTML tags.
Of course, it's up to you which way you prefer.
Originally posted by lifeh2o:
Unfortunately, Opera extension API does not support context menus.
But it's possible, like on Publog is described, but I have to add a global function, that you can use (if you're still interested).
lifeh2o # Saturday, January 22, 2011 11:04:11 AM
metude # Monday, January 24, 2011 11:48:03 AM
When i want to open a *.txt file on Opera, "Loading" is appearing on screen and doesn't loading. When i disable source extension, i can see txt file.
For example: http://ftp.opera.com/pub/opera/info/md5sum.txt
or you can try below text with selecting all then right click > go to address. (Tab Vault exporting seassion)
Also source of selection mode doesn't seeing codes of twitter image.
http://my.opera.com/chooseopera/blog/2011/01/20/10-000-views-and-1000-comments
Select first paragraph on above link, then press ctrl + f9.
My English is weak. I'm sorry for this. If you didn't understand, i can try again.
Deathamns # Monday, January 24, 2011 3:48:14 PM
Originally posted by metude:
Yeah, this is definitely a bug, at least was a bug that I've already fixed in the development version.
But with txt files I don't see any problem. For me they are working properly. Here is the actual state of my development: link. Try with this, and if still not working, then: Can you tell me what is in the Error Console when you open a txt file and what extensions you are using beside Source?
metude # Wednesday, January 26, 2011 8:19:52 PM
Originally posted by Deathamns:
Looks like txt issue fixed with RC2 (11.01). I have tested with 0.8 and 0.7. Probably it was a Opera bug.
Originally posted by Deathamns:
I'll use alpha version. Between, stable version of extension is making coloured that code of tab vault but 0.8 isn't...
metude # Sunday, January 30, 2011 8:03:05 AM
This codes is looking after last tag in page.Probably, this is about other extensions. Because I'm using almost 20 extension. But Opera's source code viewer doesn't showing that codes. Edit: This codes is looking before </body></html> tags.Deathamns # Sunday, January 30, 2011 9:26:01 AM
They (almost) always put this code into DOM regardless you use their features or not.
The version 0.8 of my code will have possibility to check the original source of a page. It will be a little slower since it uses a plus query to reload the content (I don't know any better method), and may not work on every dynamic page, because e.g., if you sign out from a site in a tab, and want to check the source in another tab where you still logged in (at least you think), then you'll get different code than what you expect.
metude # Sunday, January 30, 2011 10:44:40 AM
Have a nice working...
PengePenge4 # Wednesday, February 2, 2011 11:21:57 AM
Deathamns # Wednesday, February 2, 2011 4:55:20 PM
I'm planning to release the next beta tomorrow, maybe that will solve your problem.
PengePenge4 # Friday, February 4, 2011 10:16:18 AM
// Ezt betehetnéd még a magyarra fordított változathoz, hogy teljes legyen a leírás ott is. /* Főbb funkciók: - Aktuális DOM fa megtekintése szép kódkiemeléssel és kattintható linkekkel. Ez nem az oldal eredeti forráskódja (benne vannak például a UserJS-ek és kiegészítők által módosított részek), de a legtöbb esetben ugyanaz. - Kiválasztás vagy egyetlen elem forrásának megtekintése. - Szintaxis kiemelés, opcionális szövegtördelés és kattintható linkek a forráskódokban. Opcionális szöveg középre igazítás sima szövegeknél és NFO fájlok jobb minőségű megjelenítése. Használata: Ctrl+F9 (alapértelmezésben) az egész oldal, vagy a kiválasztás forráskódjának megnyitása. Ha az oldalon vannak frame-ek és a felső frame forrását akarod megnyitni Ctrl+Shift+F9 Ctrl+Alt+F9 újratölti a tartalmat. Például RSS esetén hasznos, ha az eredeti XML forrásra vagy kíváncsi, mert az Opera saját HTML lapot generál neki. Szerkeszteni/megnézni egy elem forrását Ctrl+Q-val tudod (miután a kék kerettel kiválasztod a megtekinteni kívánt részt. Egy elem szöveges tartalmának szerkesztéséhez nyomj Ctrl+Shift+Q-t és kattints a zöld keretre. Ctrl+Alt+Q-val tudsz node-ot eltávolítani (vagy Shift+klikk használatával azonos class-szal rendelkezőket). Itt piros kerettel tudsz választani. Space-szel tudsz váltogatni ezen 3 kiválasztási mód között. A szintaxis kiemelés automatikusan történik. További információkért látogass el a támogatási oldalra, vagy a kiegészítő beállításainak oldalára. Jövőbeli tervek: - JavaScript kódok formázása. - JavaScript/CSS tömörítés A szintaxis kiemelés ezen alapul: http://code.google.com/p/google-code-prettify/ Az ikonokért köszönet: http://esk6a.deviantart.com/ */
Deathamns # Friday, February 4, 2011 10:37:54 AM
Originally posted by Penge4:
Szándékomban állt, de nem jöttem rá, hogy hogyan lehetséges. Az a rövid leírás, ami van, a config.xml-ben szerepel (és automatikusan kapott egy új oldalt). Ha megnézed a többi többnyelvű kiterjesztést, akkor azoknál is csak egy nyelv esetében van hosszabb leírás (legalábbis én nem találtam olyat, ahol mindegyiknél lenne).
metude # Friday, February 4, 2011 12:24:35 PM
But sometimes i have to remove many element. So why i have to use shortcut for every element. I want to remove them quickly.
2-This is about Ctrl+Shift+Q. When press that shortcut second time, it should close editable content feature. This will be good. (If it possible all related shortcuts, this will be twice good.)
3- Optional toolbar icon and menu could be nice. I made a ugly concept.
http://img196.imageshack.us/img196/8466/source08betaconcept.jpg
QUESTION: I didn't work out Format CSS (F) mode?
Edit: Forget to adding concept image.
Deathamns # Friday, February 4, 2011 2:44:46 PM
2. Pressing (any of three) shortcut again will leave inspecting mode. If you want to disable contenteditable property for an element (so, when an element has a green dashed outline, and you want to remove it) you have to go into inspecting mode again (Ctrl+Shift+Q) and click on that element.
But in the future releases the Esc key will help on this.
3. Maybe the v1.0 will have toolbar icon and popup menu. But, for now, I won't give high priority for this.
Originally posted by metude:
For an example, open a CSS file and press F.
metude # Friday, February 4, 2011 6:18:01 PM
2. Still didn't leaved. http://prntscr.com/1iwib
If you're not living any problem with, maybe this is my fault.
3.
Originally posted by Deathamns:
Nice
metude # Friday, February 4, 2011 8:51:32 PM
Deathamns # Saturday, February 5, 2011 12:46:36 AM
Originally posted by metude:
I don't really understand what you say, but in javascript the two alt (or ctrl) are treated as equals (if my knowledge is correct).
mjnc95 # Saturday, February 5, 2011 1:04:01 AM
There is a slight problem with the display of HTML select box.
The select tag and All of the option tags are displayed on a Single line, with Or without line wrapping.
Adding blank lines between the option tag lines in the source code did not change the display output.
Very nice extension.
I appreciate your offering.
metude # Saturday, February 5, 2011 7:41:52 AM
Originally posted by Deathamns:
Done. Understood.
Originally posted by Deathamns:
For example in this comment form box, when i press Alt Gr + Q to add @ character. Firstly it's enabling remove element mode. If i need to add @ character, i have to press two time.
Some js codes seperating them as left alt, right alt. I have seen before...
Sorry for my weak English.
Deathamns # Saturday, February 5, 2011 5:30:19 PM
Originally posted by mjnc95:
I cannot change this behavior since Opera automatically removes the white-space inside the select tag. But not always, e.g., on this page at the bottom in language selector. I didn't figured it out how it works.
And here you can find dark 2 theme (which is actually called "desert", and here are others too: default, light, dark 1 used by this site).
Originally posted by metude:
I tested both alt key and they are always equals (at least for me).
But for removing a node, you have to use Ctrl+Alt+Q, not only Alt+Q.
Edit: I've read about AltGr and why not recommended to use Alt key for shortcuts. I'll figure out something in the next release.
Alexanders-a-s-h # Monday, February 21, 2011 11:37:52 AM
Also would be good to implement color scheme preview in settings page. I think that you already plan to add it along with custom color schemes.
PS. Thank for this brillian extension. It brings same feature reach source code viewing as in other browsers.
Deathamns # Monday, February 21, 2011 10:00:58 PM
Originally posted by s-a-s-h:
Not sure that the next, but the version 1.0 will have this too.
Daniel15daniel15 # Wednesday, February 23, 2011 10:08:00 AM
Li Haominlhmoperaunite # Wednesday, March 2, 2011 4:31:43 PM
Deathamns # Wednesday, March 2, 2011 8:47:37 PM
metude # Friday, March 11, 2011 7:05:26 AM
2. Close opened tab with that link.
3. Click that link once again.
4. Now Soruce extension will show source of page.
I tried with clean installion, too. Looks like a bug. Maybe it's a Opera's bug.
Deathamns # Friday, March 11, 2011 11:08:53 AM
metude # Friday, March 11, 2011 3:00:52 PM
Originally posted by Deathamns:
Can you report it to Opera?
I have no idea what triggering it.
İsmail YEŞİLYURTE32KERNEL # Sunday, March 13, 2011 7:46:31 PM
Unregistered user # Sunday, March 27, 2011 5:53:01 AM
Unregistered user # Monday, March 28, 2011 1:10:34 PM
Deathamns # Monday, March 28, 2011 3:35:34 PM
Originally posted by metude:
They fixed it in the build 2053.
Originally posted by anonymous:
No problem here. Maybe another extension or userJS interfere the syntax highlighting. It would be good to know what extensions you are using...
In the next update I'll make a little protection for this (if highlighting fails then plain text will appear).
Originally posted by anonymous:
Disabling shortcuts is not possible for now, maybe in future releases.
metude # Saturday, April 2, 2011 9:24:25 AM
Originally posted by Deathamns:
Originally posted by Deathamns:
This may be nice...
Unregistered user # Friday, April 15, 2011 6:18:24 PM
Deathamns # Friday, April 15, 2011 9:52:54 PM
Great Land WebGreatLand1959 # Tuesday, April 26, 2011 2:37:51 PM
Deathamns # Tuesday, April 26, 2011 3:15:40 PM
Here is the actual state of the development: 0.9.5, but it's still in the alpha phase.
I've re-written the shortcut handling, and now you can set any combination you want. Before you install, remove any previous version, and it's only compatible with the latest version of Opera (11.10).
Great Land WebGreatLand1959 # Sunday, May 1, 2011 6:56:42 AM
Originally posted by Deathamns:
Unfortunately, it appears that most (if not all) of the CMD-(letter) combinations are already assigned to various functions. So the ability to assign the hotkeys to something other than CTRL(CMD) would be welcome and beneficial. Since you are already including that in the next version, I will check it out as it gets closer to the final version.Thank you.
(P.S., your English is fine. In fact, it is better than some people who claim it as their native language!)
metude # Saturday, May 7, 2011 8:07:32 PM
Deathamns # Saturday, May 7, 2011 8:53:23 PM
Use shortcuts instead.
metude # Friday, May 13, 2011 6:33:41 PM
Deathamns # Friday, May 13, 2011 7:51:23 PM
metude # Saturday, May 14, 2011 7:00:16 AM
But looks like your browser.js file not working.
Try here: http://www.opera.com/docs/browserjs/#updateManually
then go Compose mode and press space button.
Deathamns # Saturday, May 14, 2011 11:43:28 AM
metude # Saturday, May 14, 2011 6:59:04 PM
Originally posted by Deathamns:
I'm using your quick fix now. Thanks!
metude # Sunday, May 15, 2011 9:53:40 AM
DitherDitherSky # Monday, May 16, 2011 4:17:28 AM
Is it possible to add an option to generate BB-coded text from a selection in addition to or instead of pure HTML source (with some fitting tag reduction)?