MozillaZine

[Ext] userChrome.js

Announce and Discuss the Latest Theme and Extension Releases.
neomi

User avatar
 
Posts: 2
Joined: August 8th, 2006, 5:43 pm
Location: cyber space

Post Posted August 15th, 2006, 5:40 pm

I tried to move the hole toolbox, but the same thing happened. btw, the custom toolbar window had no item in it.

Is it true that you have to keep the original structure of document for the browser to recognize it?
where?

Diorser

User avatar
 
Posts: 1000
Joined: June 22nd, 2005, 6:57 am

Post Posted August 20th, 2006, 2:54 am

Diorser wrote:
Diorser wrote:Is it possible to change default source viewer without adding any extension by using UserChrome.js or anything else but an extension ?
Coming back on that one and to clarify, and because currently using Fx1.5.0.6, is there a real technical explanation why it would not be possible to make a user js to open source with an external editor ? (something close to LaunchIE ?)
Just replacing the existing menu "View page source" command by an other editor would fit the need, without creating new button or new menus.

By replacing IE path of LaunchIE.js, it is at least possible to open an external editor instead of IE, but it opens a blank page only.
Code: Select all
      catch (ex)
      {         iexplore.initWithPath((Components.classes["@mozilla.org/process/environment;1"].
getService(Components.interfaces.nsIEnvironment).get("PROGRAMFILES") || "C:\\Program Files") + "\\Internet Explorer\\iexplore.exe");
      }

It looks weird to me that Firefox is able to open IE with a simple JS, but not an simple editor.
Then, let's try something easier.
Would it be possible to just pass the current url of the visited page to an external editor (not the html code, but just the url), by using the already existing "View Source Page Menu" and a simple JS ?
The external editor would then open itself the url.
(for background, just one line of customisation is enough with Opera !).

Zoolcar9

User avatar
 
Posts: 2225
Joined: November 9th, 2004, 6:45 pm
Location: Jakarta, Indonesia (UTC+7)

Post Posted August 20th, 2006, 7:18 am


It depends on the editor, does it enable to open a file from a URL?
example: notepad.exe http://example.com/example.txt

My Firefox information | Add-ons | GitHub

"With great power, comes great desire to show it off."

Diorser

User avatar
 
Posts: 1000
Joined: June 22nd, 2005, 6:57 am

Post Posted August 20th, 2006, 8:22 am

Yes, I use PsPad which is able to directly open an url ( http://example.com ).
It should not be more complicated than opening IE !!

Zoolcar9

User avatar
 
Posts: 2225
Joined: November 9th, 2004, 6:45 pm
Location: Jakarta, Indonesia (UTC+7)

Post Posted August 20th, 2006, 9:47 am


Try running PSPad from command line
Code: Select all
"C:\Program Files\PSPad editor\PSPad.exe" "http://static.mozillazine.org/forums/style/style-forum.css"

If you're editor doesn't open http://static.mozillazine.org/forums/style/style-forum.css, then it can't open a file directly from web location. Therefore you can't just simply modify LaunchIE script. It needs more than that.

My Firefox information | Add-ons | GitHub

"With great power, comes great desire to show it off."

Diorser

User avatar
 
Posts: 1000
Joined: June 22nd, 2005, 6:57 am

Post Posted August 20th, 2006, 11:33 am

PsPad is able to open all web locations, including http://static.mozillazine.org/forums/st ... -forum.css with no problem.
The problem is not PsPad, but what should be written in the JS file to pass the url to PsPad. Manually including the exact path of PsPad in the user JS file is not a problem.
I supppose it is a one command line, but my JS expertise is far not sufficient to pursue until the end.

Example for Opera > just add this line to a menu.ini file:
Item, "Open with PsPad"="Execute program, "D:\PsPad.exe", "%u" , , "PsPad""
and done !

Chad-)
 
Posts: 166
Joined: August 29th, 2005, 7:01 am

Post Posted August 20th, 2006, 2:14 pm

I unzipped the Context Search xpi and found a .js & a .xul file inside. I added them both to userChrome.js & everything works fine. But when I open a link in a new window & try to access the context search menu I don't know why I get this

Image

And how can I combine the 2 files into a single xul file for userChrome.xul?
Last edited by Chad-) on October 13th, 2006, 1:00 am, edited 1 time in total.

Zoolcar9

User avatar
 
Posts: 2225
Joined: November 9th, 2004, 6:45 pm
Location: Jakarta, Indonesia (UTC+7)

Post Posted August 20th, 2006, 6:31 pm


Edit script tag in contextsearch.xul to
Code: Select all
<script type="application/x-javascript" src="contextsearch.js"/>

and save contextsearch.xul and contextsearch.js in a same folder.
IMO, it's better than <a href="view-source:data:application/vnd.mozilla.xul+xml;base64,CjwhRE9DVFlQRSB3aW5kb3cgU1lTVEVNICJjaHJvbWU6Ly9icm93c2VyL2xvY2FsZS9icm93c2VyLmR0ZCI%2BCgo8b3ZlcmxheSBpZD0iY29udGV4dHNlYXJjaCIKICB4bWxucz0iaHR0cDovL3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PSAwOyBpIDwgc2VhcmNoVXJsLmxlbmd0aDsgaSsrKSB7CiAgICAgIGZpbmFsVXJsICs9IChzZWFyY2hVcmxbaV0gPT0gIisiKSA%2FICIlMjAiIDogc2VhcmNoVXJsW2ldOwogICAgfQoKICAgIHJldHVybiBmaW5hbFVybDsKCX0KfQoKd2luZG93LmFkZEV2ZW50TGlzdGVuZXIoImxvYWQiLCBjb250ZXh0c2VhcmNoLmxvYWQsIHRydWUpOwogIF1dPgogIDwvc2NyaXB0PgogICAgCiAgPHBvcHVwIGlkPSJjb250ZW50QXJlYUNvbnRleHRNZW51Ij4KICAKICAgIDxtZW51IGlkPSJjb250ZXh0LXNlYXJjaG1lbnUiCiAgICAgIGluc2VydGJlZm9yZT0iY29udGV4dC1zZWFyY2hzZWxlY3QiCiAgICAgIGFjY2Vzc2tleT0iJnNlYXJjaC5hY2Nlc3NrZXk7Ij4KICAgICAgCiAgICAgIDxtZW51cG9wdXAgaWQ9ImNvbnRleHQtc2VhcmNocG9wdXAiCiAgICAgICAgb25jb21tYW5kPSJyZXR1cm4gY29udGV4dHNlYXJjaC5zZWFyY2goZXZlbnQpOyIvPgogICAgICAgIAogICAgPC9tZW51PgogICAgCiAgPC9wb3B1cD4KICAgIAo8L292ZXJsYXk%2B">combining</a> those 2 files.

My Firefox information | Add-ons | GitHub

"With great power, comes great desire to show it off."

Chad-)
 
Posts: 166
Joined: August 29th, 2005, 7:01 am

Post Posted August 20th, 2006, 11:15 pm

Zoolcar

The problem still arises when I open a new window. The context search menu is broken until I do something like reloading the page, opening another tab, the sidebar etc.

Zoolcar9

User avatar
 
Posts: 2225
Joined: November 9th, 2004, 6:45 pm
Location: Jakarta, Indonesia (UTC+7)

Post Posted August 21st, 2006, 4:24 am


WFM

My Firefox information | Add-ons | GitHub

"With great power, comes great desire to show it off."

aronin
 
Posts: 243
Joined: November 9th, 2005, 7:31 pm

Post Posted August 21st, 2006, 3:41 pm

There is this old extension URL2NewTab (https://addons.mozilla.org/firefox/147/) ... basically opens a new tab from the URL Bar and Home button. I unzipped its xpi and found 2 JS files and 2 XUL files. Is there anyway to combine them and get them working.
My basic requirement is to be able to Open a New Tab from the Address Bar/Bookmarks/History. Can this be accomplished through userChrome.js.

Zoolcar9

User avatar
 
Posts: 2225
Joined: November 9th, 2004, 6:45 pm
Location: Jakarta, Indonesia (UTC+7)

Post Posted August 22nd, 2006, 5:40 am

aronin wrote:My basic requirement is to be able to Open a New Tab from the Address Bar/Bookmarks/History.

You don't need an extension or userChrome.js script for that.
Use alt+enter for Address Bar (it is called Location Bar on Firefox), use middle click or ctrl+left click for Bookmarks/History

My Firefox information | Add-ons | GitHub

"With great power, comes great desire to show it off."

aronin
 
Posts: 243
Joined: November 9th, 2005, 7:31 pm

Post Posted August 22nd, 2006, 6:29 am

Zoolcar9 wrote:
aronin wrote:My basic requirement is to be able to Open a New Tab from the Address Bar/Bookmarks/History.

You don't need an extension or userChrome.js script for that.
Use alt+enter for Address Bar (it is called Location Bar on Firefox), use middle click or ctrl+left click for Bookmarks/History




:-) Ofcourse I know that and thats what I do now. But I want to open a new tab from address bar when I click 'Enter' and not 'Alt enter'... similarly, new tabs from bookmarks and history on left click and not 'ctrl+left click'.

Currently I use TMP to do all this, but TMP is too huge for my small needs, hence wanted to take the JS route. So is there a solution?

On the side, I had another issue. I have been using 'Open Tabs Relative' through Userchrome.js (code as provided on the first page). There is a small anomaly though. As an example, if I 'click' open multiple links from Bloglines, it opens it towards the end of tab bar instead of next to Bloglines Tab but if I Ctrl+Click the same links in Bloglines, it opens the links next to Bloglines Tab. Can't figure whats going on. But my best guess is when I directly click a link in Bloglines or even in Google Search (with 'open result in new windows' option), the links try to open a new window which are diverted into Tabs and the code does not consider them to be 'children' of the Tab. Any input here will be appreciated.

Thanks a ton.

aronin
 
Posts: 243
Joined: November 9th, 2005, 7:31 pm

Post Posted August 23rd, 2006, 3:08 am

zeniko wrote:I've added a "Tabs to the Right" snippet which is a little bit more sophisticated (if you open two tabs in a row, the second tab will be to the right of the first one).


I am finding differing behaviors on this code, as follows:
a. Open a new tab from address bar (Alt+Enter) -> Tab is opened next to current tab
b. Open a new tab from current tab (Ctrl+Click) -> Tab is opened next to current tab
c. Open another new tab from current tab (Ctrl+Click) -> Tab is opened next to the first tab opened from the current tab
d. Open a new tab through Ctrl+T -> New Tab is opened to the END of Tab Bar
e. Click a link in Bloglines/Digg Headlines/Google Search (with the preference to open search results in a new browser window) -> New Tab is opened to the END of Tab Bar

The first three behaviors (a,b,c) are fine. Are the last two behaviors (d & e) intended? Actually behavior (d) is perfect, but I do not understand behavior (e)?

old zeniko
 
Posts: 0
Joined: December 31st, 1969, 5:00 pm

Post Posted August 23rd, 2006, 7:44 am

aronin wrote:e. Click a link in Bloglines/Digg Headlines/Google Search (with the preference to open search results in a new browser window) -> New Tab is opened to the END of Tab Bar

This behavior is pretty much untested and thus undefined. Anyway, try adding the following line to the snippet and see whether it fixes the issue:
Code: Select all
eval("nsBrowserAccess.prototype.openURI = " + nsBrowserAccess.prototype.openURI.toString().replace(/(loadOneTab\()"about:blank"/, '$1"data:text/html,"'));

Return to Extension/Theme Releases


Who is online

Users browsing this forum: No registered users and 0 guests