[Ext] userChrome.js
- dougeeebear
- Posts: 548
- Joined: September 15th, 2005, 4:17 pm
- JNewbry
- Posts: 321
- Joined: April 9th, 2005, 3:56 am
- Location: Dallas,TX
- Contact:
Code: Select all
/* This script will add "Hello, World!" menuitem before
the "Open Link in New Window" menuitem on Context Menu */
(function() {
var newItem = document.createElement("menuitem");
newItem.setAttribute("label", "Hello, World!");
newItem.setAttribute("oncommand", "alert('Hello, World!');");
var openLink = document.getElementById("context-openlink");
openLink.parentNode.insertBefore(newItem, openLink);
})();
*Corrected - Thanks zeniko!
If you have the <a href="data:text/javascript,%2F*%20%3A%3A%3A%3A%3A%3A%3A%3A%20Sub-Script%20Loader%20%3A%3A%3A%3A%3A%3A%3A%3A%3A%3A%3A%3A%3A%3A%3A%20*%2F%0A%0A%2F%2F%20automatically%20includes%20all%20files%20ending%20in%20.uc.js%20from%20the%20profile's%20chrome%20folder%0A%0A(function()%20%7B%0A%09var%20chromeDir%20%3D%20Components.classes%5B%22%40mozilla.org%2Ffile%2Fdirectory_service%3B1%22%5D.getService(Components.interfaces.nsIProperties).get(%22UChrm%22%2C%20Components.interfaces.nsILocalFile)%3B%0A%09var%20files%20%3D%20chromeDir.directoryEntries.QueryInterface(Components.interfaces.nsISimpleEnumerator)%3B%0A%09%0A%09while%20(files.hasMoreElements())%0A%09%7B%0A%09%09var%20file%20%3D%20files.getNext().QueryInterface(Components.interfaces.nsIFile)%3B%0A%09%09if%20(%2F%5C.uc%5C.js%24%2Fi.test(file.leafName))%0A%09%09%7B%0A%09%09%09setTimeout(function(aFile)%20%7B%0A%09%09%09%09Components.classes%5B%22%40mozilla.org%2Fmoz%2Fjssubscript-loader%3B1%22%5D.getService(Components.interfaces.mozIJSSubScriptLoader).loadSubScript(Components.classes%5B%22%40mozilla.org%2Fnetwork%2Fio-service%3B1%22%5D.getService(Components.interfaces.nsIIOService).getProtocolHandler(%22file%22).QueryInterface(Components.interfaces.nsIFileProtocolHandler).getURLSpecFromFile(aFile))%3B%0A%09%09%09%7D%2C%200%2C%20file)%3B%0A%09%09%7D%0A%09%7D%0A%7D)()%3B%0A">Sub-Script Loader</a> in userChrome.js..... it will recognize all files ending in .uc.js
Last edited by JNewbry on June 3rd, 2006, 8:59 am, edited 2 times in total.
<a href="http://webdesigns.ms11.net/chromeditp.html" target="_blank">ChromEdit Plus</a> | <a href="http://webdesigns.ms11.net/winstripethemes.html" target="_blank">Firefox Themes</a>
- Diorser
- Posts: 1009
- Joined: June 22nd, 2005, 6:57 am
-
- Posts: 0
- Joined: December 31st, 1969, 5:00 pm
If you use the "anonymous function" idiom to hide variables from the global scope, make sure that it looks as follows:
This creates an anonymous function and executes it in place (the parentheses surrounding the function are needed to prevent a syntax error and the parentheses at the end actually execute it).
Code: Select all
(function() {
// this code won't pollute the global scope
})();
This creates an anonymous function and executes it in place (the parentheses surrounding the function are needed to prevent a syntax error and the parentheses at the end actually execute it).
- Diorser
- Posts: 1009
- Joined: June 22nd, 2005, 6:57 am
userChrome.js again..... I don't see any effect with this one....
- <a href="data:application/x-javascript;charset=utf-8;base64,Ly9UaGlzIHNjcmlwdCB3aWxsIGFkZCAiSGVsbG8sIFdvcmxkISIgYnV0dG9uIG9uIHRoZSB0b29sYmFyDQoNCihmdW5jdGlvbigpIHsNCiAgdmFyIG5ld0J1dHRvbiA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoInRvb2xiYXJidXR0b24iKTsNCiAgbmV3QnV0dG9uLnNldEF0dHJpYnV0ZSgibGFiZWwiLCAiSGVsbG8sIFdvcmxkISIpOw0KICBuZXdCdXR0b24uc2V0QXR0cmlidXRlKCJvbmNvbW1hbmQiLCAiYWxlcnQoJ0hlbGxvLCBXb3JsZCEnKTsiKTsNCiAgbmV3QnV0dG9uLnN0eWxlLmxpc3RTdHlsZUltYWdlID0gInVybChkYXRhOmltYWdlL3BuZztiYXNlNjQsaVZCT1J3MEtHZ29BQUFBTlNVaEVVZ0FBQUJBQUFBQVFBUU1BQUFBbFBXMGlBQUFBRlhSRldIUkRjbVZoZEdsdmJpQlVhVzFsQUFmV0F4c1NLU1VONmlBZUFBQUFCM1JKVFVVSDFnTWJFaTA0MzRGcXN3QUFBQWx3U0ZsekFBQU9kQUFBRG5RQmF5U3oxZ0FBQUFaUVRGUkZBQUFBJTJGJTJGJTJGJTJGcGRtZjNRQUFBQ1ZKUkVGVWVOcGolMkJQJTJCZkFZS21uV0lvMndsQ2swNUJSYjcxTTN5WXolMkZCdFA0Z0JVd1lBaGNVYldjdWhlVDhBQUFBQVNVVk9SSzVDWUlJJTNEKSI7DQogIG5ld0J1dHRvbi5zdHlsZS5wYWRkaW5nID0gIjAiOw0KDQogIHZhciBob21lQnV0dG9uID0gZG9jdW1lbnQuZ2V0RWxlbWVudEJ5SWQoImhvbWUtYnV0dG9uIik7IC8vSG9tZSBidXR0b24NCiAgaG9tZUJ1dHRvbi5wYXJlbnROb2RlLmluc2VydEJlZm9yZShuZXdCdXR0b24sIGhvbWVCdXR0b24ubmV4dFNpYmxpbmcpOyAvL2FkZHMgdGhlIG5ldyBidXR0b24gb24gdGhlIHJpZ2h0IG9mIEhvbWUgYnV0dG9uDQoNCn0pKCk7DQoNCg%3D%3D">Adds a toolbarbutton</a>
-
- Posts: 0
- Joined: December 31st, 1969, 5:00 pm
- Diorser
- Posts: 1009
- Joined: June 22nd, 2005, 6:57 am
I get:
And following line is the last one with })();
Well, my conclusion is that without learning JavaScript, difficult to go far by just copying proposed codes found on a forum !
- Error: homeButton has no properties
Source File: file:///D:/Applis/Mozilla/FFProf/chrome/ToolbarButoon.uc.js
Line: 13
Code: Select all
homeButton.parentNode.insertBefore(newButton, homeButton.nextSibling);
Well, my conclusion is that without learning JavaScript, difficult to go far by just copying proposed codes found on a forum !
- KidReefer
- Posts: 141
- Joined: May 7th, 2006, 6:10 am
- Location: Earth...mainly
- Contact:
-
- Posts: 0
- Joined: December 31st, 1969, 5:00 pm
- Diorser
- Posts: 1009
- Joined: June 22nd, 2005, 6:57 am
Yes Home button is visible, but still absolutely no effect.
My home is set to "about:blank", and is still the same by using your files ....
"NoScript" extension problem / about:config tweak ?
Don't know, but less obvious than expected.
ps: other js files work fine, except this toolbar button.
(currently using Fx 1.5.0.4)
My home is set to "about:blank", and is still the same by using your files ....
"NoScript" extension problem / about:config tweak ?
Don't know, but less obvious than expected.
ps: other js files work fine, except this toolbar button.
(currently using Fx 1.5.0.4)
- KidReefer
- Posts: 141
- Joined: May 7th, 2006, 6:10 am
- Location: Earth...mainly
- Contact:
did you see this
Got any other scripts?
dougeeebear wrote:I found out if there is a coding mistake anywhere within userChrome.js, none of the scripts work (meaning the script with the mistake plus all other scripts).
You have to physically go and find the file and edit it and correct your mistake before anything will work again.
I guess that means don't make any mistakes.
Got any other scripts?
- KidReefer
- Posts: 141
- Joined: May 7th, 2006, 6:10 am
- Location: Earth...mainly
- Contact:
- Diorser
- Posts: 1009
- Joined: June 22nd, 2005, 6:57 am
Now solved !!!!
I used your zip files, but thought the Button test scripts was in the UCJSFiles dir !!! But not .... Just added and now works fine.
But, did not identify what went wrong with exactly the same test script few hours before.
Ok, I am now going to take a breath !
Many thanks for your precious help !
I used your zip files, but thought the Button test scripts was in the UCJSFiles dir !!! But not .... Just added and now works fine.
But, did not identify what went wrong with exactly the same test script few hours before.
Ok, I am now going to take a breath !
Many thanks for your precious help !