MozillaZine

[Ext] userChrome.js

Announce and Discuss the Latest Theme and Extension Releases.
aronin
 
Posts: 243
Joined: November 9th, 2005, 7:31 pm

Post Posted August 23rd, 2006, 9:29 pm

zeniko wrote:
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,"'));


Cool. This looks FIXED. How the hell do you figure these things out man. I spent a day trying to do this. While I am new to JS as such but still a day is a lot of time to figure out and write 2 lines of code.

I desperately need another help from you, have already wasted 3 days trying to figure this out. How can I open New Tabs from Location Bar (on Enter) / Bookmarks (on Left Click)/ History (on Left Click) respectively. As mentioned a couple of posts back, I was trying to tweak the code from an old extension url2newtab (https://addons.mozilla.org/firefox/147/) but haven't succeeded thus far. I can't say how much I will be relieved if this can be done.

Thank you so much for all the help.

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

Post Posted August 24th, 2006, 4:35 am

aronin wrote:How the hell do you figure these things out man.

Through looking at the source and figuring out how things work in general. Of course, doing that for months for several hours per day helps... ;)

aronin wrote:I desperately need another help from you

While this one was a trivial fix, the other one is not. Since I've got no time (nor motivation) to investigate your issue, I recommend you to create a new topic in the Extension Development forum.

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

Post Posted August 24th, 2006, 6:27 am

zeniko wrote:While this one was a trivial fix, the other one is not. Since I've got no time (nor motivation) to investigate your issue...


Hmm... in that case let me give it another try myself first, for several hours a day :-)

Thanks again.

max1million
 
Posts: 2810
Joined: November 15th, 2004, 5:03 am

Post Posted August 25th, 2006, 8:36 am

Diorser wrote:Just replacing the existing menu "View page source" command by an other editor would fit the need, without creating new button or new menus.

<a href="data:application/x-javascript;charset=utf-8,//%20*******%20New%20command%20for%20View%20Page%20Source%20on%20context%20menu%20*******%0A//%20*******%20appTarget%20below%20is%20the%20path%20to%20the%20external%20program%20to%20use%20*******%0A//%20*******%20it%20must%20be%20able%20to%20open%20a%20URL%20*******%0Avar%20apps%20%3D%20%7B%0A%20%20init%3A%20function%28%29%20%7B%0A%20%20%20%20%20%20appTarget%20%3D%20%22C%3A%5C%5CProgram%20Files%5C%5CInternet%20Explorer%5C%5CIEXPLORE.EXE%22%0A%20%20%20%20%20%20mItem%20%3D%20document.getElementById%28%22context-viewsource%22%29%3B%0A%20%20%20%20%20%20mItem.setAttribute%28%22oncommand%22%2C%20%22apps.run%28appTarget%29%3B%22%29%3B%0A%20%20%7D%2C%0A%20%20run%3A%20function%28appTarget%29%20%7B%0A%20%20%20%20%20%20var%20url%20%3D%20gBrowser.currentURI.spec%3B%0A%20%20%20%20%20%20var%20targetFile%20%3D%20Components.classes%5B%27@mozilla.org/file/local%3B1%27%5D.createInstance%28Components.interfaces.nsILocalFile%29%3B%0A%20%20%20%20%20%20try%20%7BtargetFile.initWithPath%28appTarget%29%7D%0A%20%20%20%20%20%20catch%28e%29%20%7Balert%28%22Can%27t%20Find%20%22%20+%20appTarget%29%7D%0A%20%20%20%20%20%20if%20%28%21%20targetFile.exists%28%29%29%20%7Balert%28%22Can%27t%20Find%20%22%20+%20appTarget%29%7D%0A%20%20%20%20%20%20var%20process%20%3D%20Components.classes%5B%27@mozilla.org/process/util%3B1%27%5D.getService%28Components.interfaces.nsIProcess%29%3B%0A%20%20%20%20%20%20var%20arguments%3D%20%5Burl%5D%20%3B%0A%20%20%20%20%20%20process.init%28targetFile%29%3B%0A%20%20%20%20%20%20process.run%28false%2C%20arguments%2C%20arguments.length%2C%20%7B%7D%29%3B%0A%20%20%7D%2C%0A%7D%0A%20apps.init%28%29%3B">View Page Source External from Context menu</a>
Edit the appTarget =

aranittara

User avatar
 
Posts: 32
Joined: July 31st, 2006, 6:25 am

Post Posted August 26th, 2006, 6:02 am

Could someone make a script that would add duplicate tab to the tab context menu
-Aranittara

Diorser

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

Post Posted August 26th, 2006, 7:24 am

max1million wrote:<a href="data:application/x-javascript;charset=utf-8,//%20*******%20New%20command%20for%20View%20Page%20Source%20on%20context%20menu%20*******%0A//%20*******%20appTarget%20below%20is%20the%20path%20to%20the%20external%20program%20to%20use%20*******%0A//%20*******%20it%20must%20be%20able%20to%20open%20a%20URL%20*******%0Avar%20apps%20%3D%20%7B%0A%20%20init%3A%20function%28%29%20%7B%0A%20%20%20%20%20%20appTarget%20%3D%20%22C%3A%5C%5CProgram%20Files%5C%5CInternet%20Explorer%5C%5CIEXPLORE.EXE%22%0A%20%20%20%20%20%20mItem%20%3D%20document.getElementById%28%22context-viewsource%22%29%3B%0A%20%20%20%20%20%20mItem.setAttribute%28%22oncommand%22%2C%20%22apps.run%28appTarget%29%3B%22%29%3B%0A%20%20%7D%2C%0A%20%20run%3A%20function%28appTarget%29%20%7B%0A%20%20%20%20%20%20var%20url%20%3D%20gBrowser.currentURI.spec%3B%0A%20%20%20%20%20%20var%20targetFile%20%3D%20Components.classes%5B%27@mozilla.org/file/local%3B1%27%5D.createInstance%28Components.interfaces.nsILocalFile%29%3B%0A%20%20%20%20%20%20try%20%7BtargetFile.initWithPath%28appTarget%29%7D%0A%20%20%20%20%20%20catch%28e%29%20%7Balert%28%22Can%27t%20Find%20%22%20+%20appTarget%29%7D%0A%20%20%20%20%20%20if%20%28%21%20targetFile.exists%28%29%29%20%7Balert%28%22Can%27t%20Find%20%22%20+%20appTarget%29%7D%0A%20%20%20%20%20%20var%20process%20%3D%20Components.classes%5B%27@mozilla.org/process/util%3B1%27%5D.getService%28Components.interfaces.nsIProcess%29%3B%0A%20%20%20%20%20%20var%20arguments%3D%20%5Burl%5D%20%3B%0A%20%20%20%20%20%20process.init%28targetFile%29%3B%0A%20%20%20%20%20%20process.run%28false%2C%20arguments%2C%20arguments.length%2C%20%7B%7D%29%3B%0A%20%20%7D%2C%0A%7D%0A%20apps.init%28%29%3B">View Page Source External from Context menu</a>
Edit the appTarget =

Thanks. It works with IE, with NVU, but not with PsPad, I don't know why.

PsPad opens the right link, but it is just a blank page with no HTML code.
If the same link is open with "Open file from Internet" PsPad command, it is just fine.

It is then more a PsPad issue which make a difference between simply opening a file, and opening a file from internet. I will investigate with PsPad team.

Diorser

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

Post Posted August 29th, 2006, 6:13 am

Based on <a href="data:application/x-javascript;charset=utf-8;base64,Ly9UaGlzIHNjcmlwdCB3aWxsIGFkZCAiSGVsbG8sIFdvcmxkISIgYnV0dG9uIG9uIHRoZSB0b29sYmFyDQoNCihmdW5jdGlvbigpIHsNCiAgdmFyIG5ld0J1dHRvbiA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoInRvb2xiYXJidXR0b24iKTsNCiAgbmV3QnV0dG9uLnNldEF0dHJpYnV0ZSgibGFiZWwiLCAiSGVsbG8sIFdvcmxkISIpOw0KICBuZXdCdXR0b24uc2V0QXR0cmlidXRlKCJvbmNvbW1hbmQiLCAiYWxlcnQoJ0hlbGxvLCBXb3JsZCEnKTsiKTsNCiAgbmV3QnV0dG9uLnN0eWxlLmxpc3RTdHlsZUltYWdlID0gInVybChkYXRhOmltYWdlL3BuZztiYXNlNjQsaVZCT1J3MEtHZ29BQUFBTlNVaEVVZ0FBQUJBQUFBQVFBUU1BQUFBbFBXMGlBQUFBRlhSRldIUkRjbVZoZEdsdmJpQlVhVzFsQUFmV0F4c1NLU1VONmlBZUFBQUFCM1JKVFVVSDFnTWJFaTA0MzRGcXN3QUFBQWx3U0ZsekFBQU9kQUFBRG5RQmF5U3oxZ0FBQUFaUVRGUkZBQUFBJTJGJTJGJTJGJTJGcGRtZjNRQUFBQ1ZKUkVGVWVOcGolMkJQJTJCZkFZS21uV0lvMndsQ2swNUJSYjcxTTN5WXolMkZCdFA0Z0JVd1lBaGNVYldjdWhlVDhBQUFBQVNVVk9SSzVDWUlJJTNEKSI7DQogIG5ld0J1dHRvbi5zdHlsZS5wYWRkaW5nID0gIjAiOw0KDQogIHZhciBob21lQnV0dG9uID0gZG9jdW1lbnQuZ2V0RWxlbWVudEJ5SWQoImhvbWUtYnV0dG9uIik7IC8vSG9tZSBidXR0b24NCiAgaG9tZUJ1dHRvbi5wYXJlbnROb2RlLmluc2VydEJlZm9yZShuZXdCdXR0b24sIGhvbWVCdXR0b24ubmV4dFNpYmxpbmcpOyAvL2FkZHMgdGhlIG5ldyBidXR0b24gb24gdGhlIHJpZ2h0IG9mIEhvbWUgYnV0dG9uDQoNCn0pKCk7DQoNCg%3D%3D">Adds a toolbarbutton</a> , I would like to open a page.html file with the added button.

I tried to replace
newButton.setAttribute("label", "Hello, World!");
newButton.setAttribute("oncommand", "alert('Hello, World!');");

by:
appTarget = "D:\\page.html";
newButton.setAttribute("oncommand", "apps.run(appTarget);");


but no success.
Any idea ?

max1million
 
Posts: 2810
Joined: November 15th, 2004, 5:03 am

Post Posted August 29th, 2006, 12:37 pm

appTarget is for an executable not a page URL.
var url = gBrowser.currentURI.spec; gets the URL of current page.
You could change it for a specific URL or file since it just a command line argument for the edior, but that would make it useles for other pages.
If you need more command line arguments they will need to be added to
var arguments= [url] ;
Example: var arguments= ['1st argument', url, '3rd argument' ] ;

If you include the whole script you should be able to use
apps.run('C:\\Program Files\\Internet Explorer\\IEXPLORE.EXE';
as a button command.

Don't know PSpad. If it can open a URL from command line? I got anther extension for that uses Metapad avaiable here. It saves a temp file first then opens it, so the editor is actually opening a local file. It has a button with context menu plus page content context menu. You can change the location to the executable for PSpad in the Settings (Options). If you want a bunch of editors try ViewSourceWith.

Diorser

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

Post Posted August 29th, 2006, 2:03 pm

Well, I try to avoid extensions as possible as I can which explains why I look for very simple scripts compared to a .... 350 KB viewsourcewith.jar !!

The problem is that I am blocked by 2 lines of JavaScript which is much too complex for me (not interested to invest time to learn JS).

BTW, I can't load Metapad Install xpi you propose for metapad. Do you have a link to load the xpi ?

Fastedit is interesting, but would be better with text hightliting which is available in source viewer.

Thanks anyway for your help !

max1million
 
Posts: 2810
Joined: November 15th, 2004, 5:03 am

Post Posted August 29th, 2006, 3:38 pm

You said PSPad can open straight from the internet (a URL). It may not do it from command line. http://gogogadgetscott.info/pspad/commandline.htm

Try the zip http://www.geocities.com/max1million/metapad.zip from the other page. The zip is 56KB but that includes the full program 104KB (unzipped) of files in the chrome folder, you can delete them and use something else, just 'Find' the exe. That leaves 27KB uncompressed for all the rest. (Quite a bit smaller then FastEdit 69KB uncompressed). (Jar are often compressed)

Fastedit from Daniel Lindkvist http://mfe.gorgias.de/
Daniel doesn't seem to be updating it or have a link to there. Text hightliting would be nice but that require more work. Cause it was using rendered htm (not the same as original somtimes) I modified the way it saves the page (same as Metapad).

Diorser

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

Post Posted August 29th, 2006, 4:34 pm

Problem solved !! Simply modified line 240 of \extensions\metapad@max.max\chrome\metapad\content\metapadOverlay.js

//**** predefined paths to metapad.exe
var metapadPath = ("D:\\PsPad\\PSPad.exe");


The metapad extension now opens PsPad. Done ! Thanks !!

Small comment on that one:
Diorser wrote:Based on <a href="data:application/x-javascript;charset=utf-8;base64,Ly9UaGlzIHNjcmlwdCB3aWxsIGFkZCAiSGVsbG8sIFdvcmxkISIgYnV0dG9uIG9uIHRoZSB0b29sYmFyDQoNCihmdW5jdGlvbigpIHsNCiAgdmFyIG5ld0J1dHRvbiA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoInRvb2xiYXJidXR0b24iKTsNCiAgbmV3QnV0dG9uLnNldEF0dHJpYnV0ZSgibGFiZWwiLCAiSGVsbG8sIFdvcmxkISIpOw0KICBuZXdCdXR0b24uc2V0QXR0cmlidXRlKCJvbmNvbW1hbmQiLCAiYWxlcnQoJ0hlbGxvLCBXb3JsZCEnKTsiKTsNCiAgbmV3QnV0dG9uLnN0eWxlLmxpc3RTdHlsZUltYWdlID0gInVybChkYXRhOmltYWdlL3BuZztiYXNlNjQsaVZCT1J3MEtHZ29BQUFBTlNVaEVVZ0FBQUJBQUFBQVFBUU1BQUFBbFBXMGlBQUFBRlhSRldIUkRjbVZoZEdsdmJpQlVhVzFsQUFmV0F4c1NLU1VONmlBZUFBQUFCM1JKVFVVSDFnTWJFaTA0MzRGcXN3QUFBQWx3U0ZsekFBQU9kQUFBRG5RQmF5U3oxZ0FBQUFaUVRGUkZBQUFBJTJGJTJGJTJGJTJGcGRtZjNRQUFBQ1ZKUkVGVWVOcGolMkJQJTJCZkFZS21uV0lvMndsQ2swNUJSYjcxTTN5WXolMkZCdFA0Z0JVd1lBaGNVYldjdWhlVDhBQUFBQVNVVk9SSzVDWUlJJTNEKSI7DQogIG5ld0J1dHRvbi5zdHlsZS5wYWRkaW5nID0gIjAiOw0KDQogIHZhciBob21lQnV0dG9uID0gZG9jdW1lbnQuZ2V0RWxlbWVudEJ5SWQoImhvbWUtYnV0dG9uIik7IC8vSG9tZSBidXR0b24NCiAgaG9tZUJ1dHRvbi5wYXJlbnROb2RlLmluc2VydEJlZm9yZShuZXdCdXR0b24sIGhvbWVCdXR0b24ubmV4dFNpYmxpbmcpOyAvL2FkZHMgdGhlIG5ldyBidXR0b24gb24gdGhlIHJpZ2h0IG9mIEhvbWUgYnV0dG9uDQoNCn0pKCk7DQoNCg%3D%3D">Adds a toolbarbutton</a> , I would like to open a page.html file with the added button.

I tried to replace
newButton.setAttribute("label", "Hello, World!");
newButton.setAttribute("oncommand", "alert('Hello, World!');");

by:
appTarget = "D:\\page.html";
newButton.setAttribute("oncommand", "apps.run(appTarget);");

I naively thought that html file extension would be internally recognized by Firefox setted as default browser. This was more an exercice than a key issue.
Thanks for your advices and explanations.

max1million
 
Posts: 2810
Joined: November 15th, 2004, 5:03 am

Post Posted August 29th, 2006, 10:43 pm

You can do that, or change the settings (Settings on toolbarbutton contextmenu or Options from Extension Manager) to override that. The path that was there was where metapad.exe was in the extension.

Code would be a bit different for opening a htm directly (like a double click) then what I had there.

Here some more basic examples:
http://kb.mozillazine.org/Running_applications
http://forums.mozillazine.org/viewtopic.php?t=446245

Diorser

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

Post Posted August 30th, 2006, 1:00 am

Thanks Max; you are magic !

To open a page.html file, I will need more time because I think it is closer to developement than Firefox tweaking. JavaScript knowlegde and much more is necessary to really tweak Firefox.

The point I even don't understand in nsIProcess below is that I want to open a page.html file from/within firefox which is already open, with an extra toolbar button, then I should not need to declare Firefox.exe which will open a new process (I suppose...).

var file = Components.classes["@mozilla.org/file/local;1"]
.createInstance(Components.interfaces.nsILocalFile);
file.initWithPath("c:\\firefox.exe");

reminder: this was more an exercice to reach the limit of user customization, than a real request !

Ria

User avatar
 
Posts: 3550
Joined: March 21st, 2004, 3:25 am
Location: Netherlands

Post Posted August 30th, 2006, 3:51 am

I tried this code, but it doesn't work and it throws an error, even if it is the only code: button has no properties.

/*======= Clear the searchbar after submit =======*/

var searchbarAutoclear = {
init: function() {
this.searchbar = document.getElementById("searchbar");
var searchbarTextbox = document.getAnonymousElementByAttribute(this.searchbar, "anonid", "searchbar-textbox");
searchbarTextbox.addEventListener("keypress", function(event) { searchbarAutoclear.clear(event); }, false);
var searchGoButton = document.getAnonymousElementByAttribute(this.searchbar, "anonid", "search-go-button");
var button = document.getAnonymousElementByAttribute(searchGoButton, "anonid", "button");
button.addEventListener("click", function(event) { searchbarAutoclear.clear(event); }, false);
},

clear: function(event) {
if ((event.keyCode == 13) || (event.button == 0)) {
setTimeout("searchbarAutoclear.searchbar.value='';", 0);
setTimeout("searchbarAutoclear.searchbar._textbox._displayCurrentEngine();", 0);
event.stopPropagation();
}
}
};
searchbarAutoclear.init();


This is really confusing, for I tried it before and then it worked I believe. Or was I hallucinating?
I tried also an older build, but it still doesn't work :? :?

Zoolcar9

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

Post Posted August 30th, 2006, 8:31 am


What version of Firefox are you using?

My Firefox information | Add-ons | GitHub

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

Return to Extension/Theme Releases


Who is online

Users browsing this forum: No registered users and 0 guests